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函数主要是用于设置编辑好的值 ,如果缺失提交数据就会报错。