Jqgrid行编码自定义控件

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章