Ski*_*les 4 javascript grid jquery plugins currency
我正在使用jsGrid JQuery插件来显示和编辑付款.虽然这是一个很好的选择,但我无法使用内置字段来编辑"付款金额".如果我使用'数字'类型,我无法在小数位后输入数字.如果我使用'text'类型,我可以输入非数字值.
到目前为止,这是我的代码
$("#jsGrid").jsGrid({
width: "100%",
height: "auto",
editing: true,
paging: true,
autoload: true,
loadIndication: true,
loadIndicationDelay: 500,
loadMessage: "Please, wait...",
loadShading: true,
controller: {
loadData: function () {
return $.ajax({
type: "GET",
url: AJAX_URL_GET_CALCULATED_AFFECTED_PAYMENTS,
data: { 'startDate': startDate, 'endDate': endDate },
dataType: "json",
cache: false,
});
},
},
fields: [
{ name: "PaymentDate", title: "Payment Date", type: "text", width: 150, editing: false, },
{ name: "PaymentEndDate", title: "Payment End Date", type: "text", width: 150, editing: false, },
{ name: "PaymentStatusDisplay", title: "Payment Status", type: "text", width: 150, align: "center", editing: false, },
{
name: "PaymentAmount", title: "Payment Amount", type: "number", width: 100, align: "center", editing: true,
itemTemplate: function(value) {
return "$" + value;
},
},
{ type: "control", deleteButton: false, editButton: true, editButtonTooltip: "Edit Amount", }
]
});
Run Code Online (Sandbox Code Playgroud)
有没有人使用这个插件得到一个例子或设法创建自定义字段类型或使用字段模板编辑jsGrid中的字段只允许货币值(数字,逗号,小数)
先感谢您.
您可以定义自定义字段,如下所示:
function MoneyField(config) {
jsGrid.NumberField.call(this, config);
}
MoneyField.prototype = new jsGrid.NumberField({
itemTemplate: function(value) {
return "$" + value.toFixed(2);
}
filterValue: function() {
return parseFloat(this.filterControl.val() || 0);
},
insertValue: function() {
return parseFloat(this.insertControl.val() || 0);
},
editValue: function() {
return parseFloat(this.editControl.val() || 0);
}
});
jsGrid.fields.money = MoneyField;
Run Code Online (Sandbox Code Playgroud)
现在您可以在字段指定中使用它 type="money"