Forum


20:52

24/09/2010

I'm new to jqGrid, so bear with me if this is obvious in the manual... 🙂
I have the jqGrid defined as:
jQuery("#project").jqGrid({
url: 'myurl',
postData: {
whereclause: ""
},
datatype: 'json',
......
By default, when requesting new data jqGrid is appending myurl like this:
myurl?page=1&rows=10&mysort=myindex&sord=asc&colname='abc'
Instead, I want to build the whereclause in postdata on the fly:
myurl?page=1&rows=10&whereclause="where colname='abc' order by myindex asc"
Basically I have a SQL built into myurl: "select * from mytable %1", and the whereclause will be replacing the %1.
Any idea how I should proceed? Thanks in advance.
06:01

24/09/2010

I figured out by myself:
beforeRequest: function() {
var inputlabel1 = ' where 1=1 ';
var postData = $("#project").jqGrid('getGridParam','postData') ;
var colModel = $("#project").jqGrid('getGridParam','colModel') ;
$.each(postData,function(the_key,the_value) {
$.each(colModel, function(idx,the_item){
if (the_item.index==the_key) inputlabel1 += ' and '+ the_key + " like '%"+the_value+"%'"
})
});
if (postData.sidx) inputlabel1 += ' order by '+ postData.sidx + ' ' + postData.sord
//alert(inputlabel1);
postData.inputlabel1=inputlabel1;
$("#project").jqGrid('setGridParam',{'postData':postData});
},
Most Users Ever Online: 715
Currently Online:
76 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66