Hi,
Can you please help on this functionality. I am searching in google for this functionality but till now am not getting any link for this.
My requirement is. I created one filter toolbar in the header in jqgrid. i created one column is called ‘End Date’ which is a drop down menu. I loaded two values ‘next 90 days’ and ‘next 180 days’. when i select next 90 days it will be filtered the data based on dropdown value. i have given my code. Please check and let me know if i wrong any thing below the code.
var mygrid = jQuery("#gridcontactalerts").jqGrid({
url: "assets/json/contactalertdata.json",
datatype: "json",
mtype:"post",
colNames:['Date','Type','Category','Note','End Date'],
colModel:[
{name:'enddate',index:'enddate',stype:'select', formatoptions:{baseLinkUrl:'index.html', addParam: ''}, align:"left", sorttype:"date",editoptions:{value:":All;Next 90 Days:Next 90 Days;Next 180 Days:Next 180 Days"},searchoptions:{dataEvents:[{type:'change',fn:function(e){dateResult(e.target.value)}}]}}
],
jsonReader : { repeatitems: true, cell: "", id: "1"}
});
function dateResult(v){
var g = $('#gridcontactalerts');
var curdateobj = new Date();
var curmonth = curdateobj.getMonth()+1;
var curdate = curdateobj.getDate();
var curyear = curdateobj.getFullYear();
var today = (curmonth)+'/'+curdate+'/'+curyear;
var d;
if(v=="Next 90 Days")
d = (curmonth+3)+'/'+curdate+'/'+curyear;
else if(v=="Next 180 Days"){
d = (curmonth+6)+'/'+curdate+'/'+curyear;
}
var f = {groupOp:"AND",rules:[]};
f.rules.push({field:'enddate',op:'ge',data:today},{field:'enddate',op:'le',data:d});
g[0].p.search = true;
$.extend(g[0].p.postData,{filters:JSON.stringify(f)});
g.trigger("reloadGrid");
}
Its not filtertering the data when i select the values from the dropdown. Can you please check and let me know.