I want support for drop-downs in the toolbar filter fields as Filter toolbar drop-down not working in jqgrid 4.6.0 version. But it is working in 3.8 .version
I have referred the link for 3.8.
Please help me to fix in 4.6.0 version.
jQuery(document).ready(function() {
var categories = ["All", "sport", "science"];
var categoriesStr = ":All;1:sport;2:science";
var subcategories = ["All", "football", "formel 1", "physics", "mathematics"];
var subcategoriesStr =":All;1:football;2:formel 1;3:physics;4:mathematics";
var mydata = [
{id:0, Name:"Lukas Podolski", Category:1, Subcategory:1},
{id:1, Name:"Michael Schumacher", Category:1, Subcategory:2},
{id:2, Name:"Albert Einstein", Category:2, Subcategory:3},
{id:3, Name:"Blaise Pascal", Category:2, Subcategory:4}
];
var grid = jQuery("#list").jqGrid({
data: mydata,
datatype: 'local',
colModel: [
{ name: 'Name', index: 'Name', width: 200},
{ name: 'Category', index: 'Category', width: 200, formatter:'select', stype: 'select',
sorttype: function(cell) {return categories[cell];},
edittype:'select', editoptions: { value: categoriesStr },
searchoptions:{ sopt:['eq'] }
},
{ name: 'Subcategory', index: 'Subcategory', width: 200, formatter:'select', stype: 'select',
sorttype: function(cell) {return categories[cell];},
edittype:'select', editoptions: { value: subcategoriesStr},
searchoptions:{ sopt:['eq'] }
}
],
sortname: 'Name',
viewrecords: true,
rownumbers: true,
sortorder: "desc",
ignoreCase: true,
pager: '#pager',
caption: "Setting filter in the filter toolbar"
}).jqGrid('navGrid','#pager', { edit: false, add: false, del: false, search: false, refresh:false });
grid.jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn", beforeSearch: function() {
//alert("verifying the data");
var postData = grid.jqGrid('getGridParam','postData');
// we use `stringResult: true` so decoding of the search parameters are a little complex
var searchData = jQuery.parseJSON(postData.filters);
for (var iRule=0; iRule<searchData.rules.length; iRule++) {
if (searchData.rules[iRule].field === "Name") {
var valueToSearch = searchData.rules[iRule].data;
if (valueToSearch.length != 5) {
alert ("The search string MUST de 5 charachters length!");
return true; // error
}
}
}
return false;
}});
});
I have attached 4.6.0 version screen shot.
gridComplete
function if we are not usinglocal
data? I have a grid pulling data from a JSON source and all I'm getting areselect
boxes with one option in them:All
– Cricoid