How do make datepicker onselect function works differently in toolbar search and advanced search in jqgrid

后端 未结 1 1029
无人及你
无人及你 2020-12-20 01:18

I want the onselect event only do his job only on toolfilter not in advanced search.

Here is my grid:

$(\'#grid\').jqGrid({
            colNames: [\'         


        
相关标签:
1条回答
  • 2020-12-20 01:57

    You can for example use the fact that the id of elements inside of searching toolbar will be cnstructed with "gs_" prefix. So the implementation could be about the following

    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');
                }
            }    
        });
    }
    

    see the answer with very close code.

    0 讨论(0)
提交回复
热议问题