Jqgrid行編碼自定義控件
列設置
{
name: 'price',
index: 'price',
editable: true,
sortable: false,
edittype: 'custom',
editoptions: { custom_element: cus_eidt_num, custom_value: cus_eidt_num_value, class: 'text-center', maxlength: '10' }
},
函數
//定自定義控件
function cus_eidt_num(value, options) {
var html = '<input type="number" data-decimals="2" value="" maxlength="10" max="999999999" min="0" class="form-control" />';
var t = $(html);
t.val(value);
return $(t);
}
//定自定義控件 賦值
function cus_eidt_num_value(elem, operation, value) {
if (operation === 'get') {
return $(elem).val();
} else if (operation === 'set') {
$(elem).val(value);
}
}
效果
注意事項:
cus_eidt_num_value函數主要是用於設置編輯好的值 ,如果缺失提交數據就會報錯。