Free-jgrid 和输入掩码:在内联编辑模式下键入时格式化数字
Free-jgrid and input mask: Format number while type in inline edit mode
我正在使用 free-jqgrid v.4.15.4
我想在内联编辑模式下键入时格式化数字。
我正在使用 RobinHerbots 的产品 Inputmask 来制作这个。
它适用于 jqgrid v.4.6.0,但不适用于 free-jqgrid。
那么我该怎么做才能解决这个问题?
这是 2 个 jsfiddle:
Jqgrid v.4.6.0:demo with jqgrid 和
免费 jqgrid v.4.15.4:demo with free-jqgrid
var mydata = [{
name: "Toronto",
country: "Canada",
continent: "North America",
quantity: 1200000
}, {
name: "New York City",
country: "USA",
continent: "North America",
quantity: 2200000
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America",
quantity: 3200000
}, {
name: "Paris",
country: "France",
continent: "Europe",
quantity: 4200000
}]
$("#grid").jqGrid({
data: mydata,
datatype: "local",
colNames: ["Name", "Country", "Continent","Quantity"],
colModel: [{
name: 'name',
index: 'name',
editable: true,
}, {
name: 'country',
index: 'country',
editable: true,
}, {
name: 'continent',
index: 'continent',
editable: true,
},{
name: 'quantity',
index: 'quantity',
editable: true,
formatter:'number',
formatoptions:{decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2}
}],
pager: '#pager',
'cellEdit': true,
afterEditCell: function (rowid, cellname, value, iRow, iCol) {
$('#' + rowid + '_quantity').inputmask("decimal", {
radixPoint: '.',
groupSeparator: ',',
digits: 2,
autoGroup: true,
rightAlign: false,
clearMaskOnLostFocus: false
});
},
'cellsubmit' : 'clientArray',
editurl: 'clientArray'
});
原因很简单:您使用了 rowid
而不是 iRow
。固定码为
afterEditCell: function (rowid, cellname, value, iRow, iCol) {
$('#' + iRow + '_' + cellname).inputmask("decimal", {
radixPoint: '.',
groupSeparator: ',',
digits: 2,
autoGroup: true,
rightAlign: false,
clearMaskOnLostFocus: false
});
}
我正在使用 free-jqgrid v.4.15.4
我想在内联编辑模式下键入时格式化数字。
我正在使用 RobinHerbots 的产品 Inputmask 来制作这个。
它适用于 jqgrid v.4.6.0,但不适用于 free-jqgrid。
那么我该怎么做才能解决这个问题?
这是 2 个 jsfiddle:
Jqgrid v.4.6.0:demo with jqgrid 和
免费 jqgrid v.4.15.4:demo with free-jqgrid
var mydata = [{
name: "Toronto",
country: "Canada",
continent: "North America",
quantity: 1200000
}, {
name: "New York City",
country: "USA",
continent: "North America",
quantity: 2200000
}, {
name: "Silicon Valley",
country: "USA",
continent: "North America",
quantity: 3200000
}, {
name: "Paris",
country: "France",
continent: "Europe",
quantity: 4200000
}]
$("#grid").jqGrid({
data: mydata,
datatype: "local",
colNames: ["Name", "Country", "Continent","Quantity"],
colModel: [{
name: 'name',
index: 'name',
editable: true,
}, {
name: 'country',
index: 'country',
editable: true,
}, {
name: 'continent',
index: 'continent',
editable: true,
},{
name: 'quantity',
index: 'quantity',
editable: true,
formatter:'number',
formatoptions:{decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2}
}],
pager: '#pager',
'cellEdit': true,
afterEditCell: function (rowid, cellname, value, iRow, iCol) {
$('#' + rowid + '_quantity').inputmask("decimal", {
radixPoint: '.',
groupSeparator: ',',
digits: 2,
autoGroup: true,
rightAlign: false,
clearMaskOnLostFocus: false
});
},
'cellsubmit' : 'clientArray',
editurl: 'clientArray'
});
原因很简单:您使用了 rowid
而不是 iRow
。固定码为
afterEditCell: function (rowid, cellname, value, iRow, iCol) {
$('#' + iRow + '_' + cellname).inputmask("decimal", {
radixPoint: '.',
groupSeparator: ',',
digits: 2,
autoGroup: true,
rightAlign: false,
clearMaskOnLostFocus: false
});
}