【问题标题】:How do make datepicker onselect function works differently in toolbar search and advanced search in jqgrid如何使 datepicker onselect 函数在 jqgrid 中的工具栏搜索和高级搜索中的工作方式不同
【发布时间】:2012-10-22 08:15:41
【问题描述】:

我希望 onselect 事件只在 toolfilter 上而不是在高级搜索中完成他的工作。

这是我的网格:

$('#grid').jqGrid({
            colNames: ['Title', 'date'],
            colModel: [
                { name: 'Title', index: 'Title', searchoptions: { sopt: ['cn']} },
                { name: 'date', index: 'date', search: true, searchoptions: {
                    sopt: ['deq', 'dge', 'dlt'],
                    dataInit: function (el) {
                        $(el).datepicker({ onSelect: function (dateText, inst) { $("#grid")[0].triggerToolbar(); } });
                    }
                }, width: 70
                }
              ],
            pager: jQuery('#pager'),
            hidegrid: false,
            sortname: "date",
            sortorder: "desc",
            rowNum: 20,
            rowList: [10, 20, 50, 100],
            autowidth: true,
            width: "100%",
            height: "100%",
            datatype: 'json',
            viewrecords: true,
            mtype: 'POST',
            url: '<url>'

        })

【问题讨论】:

    标签: jquery jqgrid


    【解决方案1】:

    例如,您可以使用以下事实:搜索工具栏内的元素的id 将使用"gs_" 前缀进行构造。所以实现可能是关于以下的

    dataInit: function (elem) {
        $(elem).datepicker({
            changeYear: true,
            changeMonth: true,
            showButtonPanel: true,
            onSelect: function () {
                var $grid, grid;
                if (typeof (elem.id) === "string" && this.id.substr(0, 3) === "gs_") {
                    // in case of searching toolbar
                    $grid = $(elem).closest('div.ui-jqgrid-hdiv')
                                   .next('div.ui-jqgrid-bdiv')
                                   .find("table.ui-jqgrid-btable:first");
                    if ($grid.length > 0) {
                        grid = $grid[0];
                        if ($.isFunction(grid.triggerToolbar)) {
                            setTimeout(function(){
                                grid.triggerToolbar();
                            }, 50);
                        }
                    }
                } else {
                    // refresh the filter in case of
                    // searching dialog
                    $(this).trigger('change');
                }
            }    
        });
    }
    

    使用非常接近的代码查看the answer。

    【讨论】:

      猜你喜欢
      • 2011-08-21
      • 1970-01-01
      • 1970-01-01
      • 2012-06-04
      • 2011-07-26
      • 1970-01-01
      • 2012-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多