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
passing variables to gqgrid
08/08/2008
15:00
Avatar
jemison
Member
Members
Forum Posts: 13
Member Since:
08/08/2008
sp_UserOfflineSmall Offline

hello,

Im trying to pass some params to the grid.

Im doing a search tool and I want to pass 2 params from a dropdown and textfield, so I can search the DB accordingly.

how do I get thoses values on the server side?

08/08/2008
18:32
Avatar
canvas.wang
Member
Members
Forum Posts: 11
Member Since:
21/07/2008
sp_UserOfflineSmall Offline

I just did it. in grid.base.js, do the following:

$.fn.jqGrid = function(p) {

    p = $.extend([

    ...

   myParam1: 'haha1'   // default value for my parameter

   myParam2: 'haha2'

    ...

    ]}

}

Then look for  the following code in the same javascript file:

var populate = function() {

    if (!grid.hDiv.loading) {  

       beginReq();

       // modify the following line by adding the two parameters

       var  gdata = $.extend(ts.p.postData, (myParam1: ts.p.myParam1, myParam2:  ts.p.myParam2, .....))

       ....

    }

}

And then you can use the two parameters. Good luck.

09/08/2008
09:17
Avatar
jemison
Member
Members
Forum Posts: 13
Member Since:
08/08/2008
sp_UserOfflineSmall Offline

okay, I followed your instructions, but still can't get it to work.

I have something like that in example.html:

<script type=”text/javascript”>
     jQuery(document).ready(function(){
     $(”#s_search”).click(function(){
        jQuery(”#list2″).jqGrid({
         url:'example.php?nd='+new Date().getTime(),

  ….. }); });});
</script>

….
<select id=”param1” name=”param1″>
<option value=”0″ selected=”selected”>Search BY</option>
<option value=”idOrder”>No</option>
<option value=”customerName”>Client name</option>
<option value=”childName”>Child Name</option>
</select>
<input type=”text” id=”param2″ name=”param2″ value=”">
<input type=”submit” name=”s_search” id=”s_search” value=”Search”>

<table id=”list2″ class=”scroll” cellpadding=”0″ cellspacing=”0″></table>
<!– pager definition. class scroll tels that we want to use the same theme as grid –>
<div id=”pager2″ class=”scroll” style=”text-align: center;”></div>
….

now, how do I get the value of param1 and param2 in example.php?

10/08/2008
11:05
Avatar
jemison
Member
Members
Forum Posts: 13
Member Since:
08/08/2008
sp_UserOfflineSmall Offline

I found a way!!!

in example.html

<td><button onclick=”gridReload()” id=”s_search” style=”margin-left:30px;”>Search</button></td>

..

function gridReload(){
       var param1 = jQuery(”#param1″).val();
       var param2 = jQuery(”#param2″).val();
jQuery(”#list2″).setGridParam({url:”example.php?param1=”+param1+”&param2=”+param2,page:1}).trigger(”reloadGrid”);}

and, in example.php

$param1 = $_REQUEST['param1'];

$param2 = $_REQUEST['param2'];

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
34 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