Javascript 如何向JsGrid自定义sortStrategies函数传递其他参数?
我使用的是JsGrid v1.5.3,我使用JsGrid成功地创建了这样一个字段Javascript 如何向JsGrid自定义sortStrategies函数传递其他参数?,javascript,jquery,javascript-objects,jsgrid,Javascript,Jquery,Javascript Objects,Jsgrid,我使用的是JsGrid v1.5.3,我使用JsGrid成功地创建了这样一个字段 { name: "1_price", className: 'wordwrap', title: 'Test Price', type: "text", width: 75, filtering: false, sorting: true, sorter: 'priceSorter', itemTempl
{
name: "1_price",
className: 'wordwrap',
title: 'Test Price',
type: "text",
width: 75,
filtering: false,
sorting: true,
sorter: 'priceSorter',
itemTemplate: function(value, item) {
if (typeof value === 'undefined') value = '';
if (item && item.hasOwnProperty('is_sold_out') && item.is_sold_out == 1) {
return '<span class="sold-out-strikethrough">' + value + '</span>';
} else {
return '<span>' + value + '</span>';
}
}
}
从console.log(arguments)
它只发送2个参数值,如何扩展它以便接收其他参数,例如,其他参数是字段名(1_price):
通过在数组或JSON对象中定义多个参数,可以发送多个参数
window.jsGrid.sortStrategies.priceSorter = function({price1:price1, price2:price2, fieldName:fieldName}) {
console.log(arguments)
}
或
或
通过在数组或JSON对象中定义多个参数,可以发送多个参数
window.jsGrid.sortStrategies.priceSorter = function({price1:price1, price2:price2, fieldName:fieldName}) {
console.log(arguments)
}
或
或
window.jsGrid.sortStrategies.priceSorter = function({price1:price1, price2:price2, fieldName:fieldName}) {
console.log(arguments)
}
var params = {price1:price1, price2:price2, fieldName:fieldName};
window.jsGrid.sortStrategies.priceSorter = function(params) {
console.log(arguments)
}
var params = [price1, price2, fieldName];
window.jsGrid.sortStrategies.priceSorter = function(params) {
console.log(arguments)
}