views:

61

answers:

1

Hi!

I have jqgrid :

    jQuery("#list").jqGrid( {
            url : 'ajax/get',
            datatype : 'json',
            mtype : 'POST',
            colNames : [
                'Date',
                'ID'
            ],
            colModel : [{
                    name : 'date',
                    index : 'date',
                    width : 60,
              align : 'center',
                    searchoptions:{sopt:['gt', 'lt']}
                },{
                    name : 'id',
                    index : 'id',
                    width : 40,
              align : 'center',
                    searchoptions:{sopt:['eq']}
                }]
   //.......
        });

Is there a way to set "odata" option in "Date" column. Now it's showing "greater" and "less". I need - "from" and "to".

I try this :

colModel : [{
                    name : 'date',
                    index : 'date',
                    width : 60,
                    align : 'center',
                    searchoptions:{sopt:['gt', 'lt'], odata:['from', 'to']}
                }

It's not working, still showing "greater" and "less". Tried this :

$(document).ready(function(){
  $.jgrid.search = {
    odata : ['equal','not equal', 'to', 'less or equal','from','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain']
  };
  $.extend($.jgrid.search);
});

It's replaces "greater" to "from" and "less" to "to" in all columns, but I need only in "Date" column. Is there a way to do it?

Thanks.

A: 

To use searching in jqGrid you call probably navGrid function to add navigator with the search button. The function navGrid has as the 6-th parameter an object (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator#definition) which can be used to overwrite any default parameters from $.jgrid.search inclusive odata parameter. So you can do something like following

jQuery("#list").jqGrid('navGrid','#pager',{search:true},{},{},{},
                {odata:['equal','not equal', 'to', 'less or equal','from',
                        'greater or equal', 'begins with','does not begin with',
                        'is in','is not in','ends with','does not end with',
                        'contains','does not contain']});
Oleg
It's not working. Rules not changing. In spite of this, I think this code will also replace global $.jqgrid.search, but I need only in "Date" column.
andser
You should better test your code before writing a comment. Look at the source code of http://www.ok-soft-gmbh.com/jqGrid/ClientsideEditing3.htm, modify data with double-click and try with searching for "Name" of "Group" fields. Everything work. Parameters of `navGrid` of cause DON'T overwrite the global settings from the `$.jqgrid.search`.
Oleg