0

I am trying to store and load the search template using the database. While doing that, I am unable to change the value of the tmplLabel, tmplNames,tmplFilters. I am calling loadTemplates() function that goes to the server to get the data and store in 3 variables. This function is being called at loadComplete(). Please let me know how can I reset the value of the templates. I am talking about something like http://www.trirand.com/blog/jqgrid/jqgrid.html

Sukesh Kumar
  • 133
  • 2
  • 12

1 Answers1

0

Searching Templates is an interesting feature which are not frequently used. To use it one should use tmplNames and tmplFilters (optionally tmplLabel) which are parameters of the searching module. If's important that you use recreateFilter: true option additionally. So you can set the options of

var mySearchOptions = {
        // it's just some options which you use
        multipleSearch: true,
        multipleGroup: true,
        recreateFilter: true,
        closeOnEscape: true,
        closeAfterSearch: true,
        overlay: 0
    },
    $grid = $("#grid");

$grid.jqGrid({
    // ... your jqGrid options
    loadComplete: function (data) {
        // you should modify the next line correspond to the place of
        // tmplNames and tmplFilters in the server response
        if (data.tmplNames && data.tmplFilters) {
            mySearchOptions.tmplNames = data.tmplNames;
            mySearchOptions.tmplFilters = data.tmplFilters;
        }
    }
});
$grid.jqGrid('navGrid', {/*navGrid option*/}, {/*Edit options*/}, {/*Add options*/},
    {/*Del options*/},
    mySearchOptions);

I suppose that you have already correct code, but you don't use recreateFilter: true option. So previous opened Searching Dialog will be shown instead of to recreate the dialog with current options.

P.S. I recommend you additionally refresh the sources of jqGrid 4.3.2 (see the answer). You will have better keyboard support, can use searchOnEnter and closeOnEscape options, afterChange callback and custom controls in the searching dialog (see the answer).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798