jqGrid filter toolbar show search operator selector just for single column -


i have jqgrid table many columns. searching in grid made using filter toolbar. of them search simple default operator. 1 datetime column want different kind of operators , datepicker selector. have added datainit datepicker initialization searchoptions, necessary operators searchoptions.sopt. show operators have set searchoperators true. column ok. have datepicker operator selector popup. other columns default operator icon shown on left of it. annoying operator default , user couldn't change it. there possibility hide them using jqgrid api? far see hide using custom code:

i need check column model , after rendering of grid (may in loadcomplete) columns have empty sopt or sopt.length == 0 remove operator selector. or add css class hide it. not sure of these solution better (hide or remove) because removing broke logic, , hiding affect width calculation. here sample of mean on fiddle

function fixsearchoperators() {     var columns = jquery("#grid").jqgrid ('getgridparam', 'colmodel');     var gridcontainer = $("#grid").parents(".ui-jqgrid");     var filtertoolbar = $("tr.ui-search-toolbar", gridcontainer);      filtertoolbar.find("th").each(function()     {         var index = $(this).index();         if(!(columns[index].searchoptions &&              columns[index].searchoptions.sopt &&              columns[index].searchoptions.sopt.length>1))         {             $(this).find(".ui-search-oper").hide();         }     }); } 

does have better ideas?

i find idea define visibility of searching operations in every column idea. +1 me.

i suggest change little criteria choosing columns of searching toolbar searching operations. seems me more native include new property inside of searchoptions. can write like

searchoptions: {     searchoperators: true,     sopt: ["gt", "eq"],     datainit: function(elem) {         $(elem).datepicker();     } } 

i think columns, columns stype: "select", still need have sopt (at least sopt: ["eq"]), 1 don't want see search operators such columns. specifying of visibility of searching operations on column level practical in such cases.

the modified fiddle demo can find here. included in demo css the fix (see the answer , the corresponding bug report). full code below

var dataarr = [     {id:1, name: 'steven', surname: "sanderson", startdate:'06/30/2013'},     {id:2, name: "valery", surname: "vitko", startdate: '07/27/2013'},     {id:3, name: "john", surname: "smith", startdate: '12/30/2012'}];  function fixsearchoperators() {     var $grid = $("#grid"),         columns = $grid.jqgrid ('getgridparam', 'colmodel'),         filtertoolbar = $($grid[0].grid.hdiv).find("tr.ui-search-toolbar");      filtertoolbar.find("th").each(function(index) {         var $searchoper = $(this).find(".ui-search-oper");         if (!(columns[index].searchoptions && columns[index].searchoptions.searchoperators)) {             $searchoper.hide();         }     }); }  $("#grid").jqgrid({     data: dataarr,     datatype: "local",     gridview: true,     height: 'auto',     hoverrows: false,     colmodel: [         { name: 'id', width: 60, sorttype: "int"},         { name: 'name', width: 70},         { name: 'surname', width: 100},         { name: 'startdate', sorttype: "date", width: 90,             searchoptions: {                 searchoperators: true,                 sopt: ['gt', 'eq'],                 datainit: function(elem) {                     $(elem).datepicker();                 }             },             formatoptions: {                 srcformat:'m/d/y',                 newformat:'m/d/y'             }         }     ] });  $("#grid").jqgrid('filtertoolbar', {     searchonenter: false,     ignorecase: true,     searchoperators: true }); fixsearchoperators(); 

it displays same result youth:

enter image description here


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -