Easyui的datagrid的editor(行編輯器)如何擴展datetimebox類型


在easyui的datagrid擴展方法中添加這樣的時間日期(datetimebox)代碼塊

放在   $.extend($.fn.datagrid.defaults.editors,{datetimebox...}方法下

      $.extend($.fn.datagrid.defaults.editors, {
            label: {
                init: function (container, options) {
                    var input = $('<div></div>').appendTo(container);
                    return input;
                },
                destroy: function (target) {

                },
                getValue: function (target) {
                    return $(target).html();
                },
                setValue: function (target, value) {
                    $(target).html(value);
                },
                resize: function (target, width) {

                }
            },
             //擴展dategrid的editors的類型
            datetimebox: {
                init: function (container, options) {
                    var input = $('<input type="text" class="easyui-datetimebox">')
                      .appendTo(container);
                    //編輯框延遲加載
                    window.setTimeout(function () {
                        input.datetimebox($.extend({ editable: false }, options));
                    }, 10);                 
                    return input;
                },
                getValue: function (target) {
                    return $(target).datetimebox('getValue');
                },
                setValue: function (target, value) {
                    $(target).val(value);
                    window.setTimeout(function () {
                        $(target).datetimebox('setValue', value);
                    }, 150);
                },
                resize: function (target, width) {
                    var input = $(target);
                    if ($.boxModel == true) {
                        input.width(width - (input.outerWidth() - input.width()));
                    } else {
                        input.width(width);
                    }
                }
            }
        });    

我是在label下加,找到這方法,在原先擴展下面追加一個datetimebox

頁面上就可以使用editor={type='datetimebox'}這樣的寫法了

 <th field="BirthDate" sortable="true" align="center" width="150" editor="{type:'datetimebox',options:{required: true}}" formatter="com.formatTime">出生日期</th>

效果如下圖:

Ps:

參考來源網址: http://blog.csdn.net/leiyong0326/article/details/41942955


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM