Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Building postdata
24/09/2010
20:52
Avatar
kxlin
Member
Members
Forum Posts: 16
Member Since:
24/09/2010
sp_UserOfflineSmall Offline

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.

24/09/2010
20:55
Avatar
kxlin
Member
Members
Forum Posts: 16
Member Since:
24/09/2010
sp_UserOfflineSmall Offline

The reason why I need to do this is because I'm not using PHP/ASP and have little control over server side script.

25/09/2010
06:01
Avatar
kxlin
Member
Members
Forum Posts: 16
Member Since:
24/09/2010
sp_UserOfflineSmall Offline

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});            
    },

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information