【问题标题】:How To use Custom Control in jqGrid如何在 jqGrid 中使用自定义控件
【发布时间】:2012-02-02 11:01:16
【问题描述】:

如何在 Jqgrid for Field 中使用自定义控件。在添加/编辑弹出窗口中的示例我有一个日期字段,我想使用 persionDatePiker,这些设置如何?

谢谢大家,

【问题讨论】:

    标签: jqgrid jqgrid-asp.net


    【解决方案1】:

    您需要将edittype 设置为custom 并提供custom_elementcustom_value 函数。文档中的示例:

    <script>
    function myelem (value, options) {
      var el = document.createElement("input");
      el.type="text";
      el.value = value;
      return el;
    }
    
    function myvalue(elem, operation, value) {
        if(operation === 'get') {
           return $(elem).find("input").val();
        } else if(operation === 'set') {
           $('input',elem).val(value);
        }
    }
    
    jQuery("#grid_id").jqGrid({
       colModel: [ 
          {
            name:'price',
            editable:true, 
            edittype:'custom', 
            editoptions:{
                custom_element: myelem, 
                custom_value:myvalue
            }
         },
       //...
       ]
    });
    </script>
    

    但是为了整合,例如jQuery UI Datepicker我使用了以下代码:

    {
        name:'startTime',
        label: 'Start time',
        editable: true,
        editoptions: {
            dataInit: function (e) {
                $(e).datetimepicker({});
            }
        }
    }
    

    详情请见Common Editing Properties

    【讨论】:

    • ,我用jQuery为PersianToolpack写了一个控件,如何使用?我使用 asp.net。谢谢
    猜你喜欢
    • 1970-01-01
    • 2011-04-15
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    相关资源
    最近更新 更多