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函數主要是用於設置編輯好的值 ,如果缺失提交數據就會報錯。

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