Jquery EasyUI扩展中传递参数

1.扩展(在options中定义日期格式)
$.extend($.fn.datagrid.defaults.editors, {
    myDate97: {
        init: function (container, options) {
            options = options || { dateFmt: "yyyy-MM-dd HH:mm:ss" };
            var input = $('<input  class="Wdate datagrid-editable-input" onclick="WdatePicker({dateFmt:\'' + options.dateFmt + '\',readOnly:true});"  />').appendTo(container);
            return input;
        },
        getValue: function (target) {
            return $(target).val();
        },
        setValue: function (target, value) {
            $(target).val(value);
        },
        resize: function (target, width) {
            var input = $(target);
            if ($.boxModel == true) {
                input.width(width - (input.outerWidth() - input.width()));
            } else {
                input.width(width);
            }
        }
    }
});

2.调用
$("#dd").datagrid({
        searchbar:
                { forms: [
                       {
                           type: "text",
                           name: "ShiJianDuanMingCheng",
                           id: "ShiJianDuanMingCheng",
                           label: "时间段名称"
                       },
                       {
                           type: "myDate97",
                           name: "KaiShiShiJian",
                           id: "KaiShiShiJian",
                           label: "开始时间",
                           options: { dateFmt: "HH" }
                       },
                       {
                           type: "myDate97",
                           name: "JieShuShiJIan",
                           id: "JieShuShiJian",
                           label: "结束时间"
                           ,options: { dateFmt: "HH" }
                       }
                      ]
                }
});

PS: 看到extend中的扩展复制了三份,my97,my98,my99,只是因为时间格式不同,本人对jquery了解也不深入;只是拿options来试下,一切和预想的一样。

 

posted @ 2017-08-02 10:40  Coder_小菜  阅读(224)  评论(0编辑  收藏  举报