Forum


06:57

27/06/2008

I'm working with two tables, one containing schools, the other years for the schools. I'm trying to select a school then set the url for the editGridRow function to parse the php. This is the code to add a year to a school:
$(”#addyear”).click(function(){
bb = jQuery(”#schools”).getSelectedRow();
alert(bb);
if( bb != null ) {
jQuery(”#years”).editGridRow('new',{
height:100,
width:200,
reloadAfterSubmit:false,
closeAfterAdd:true,
closeAfterEdit:true,
drag:true,
modal:true,
url:'setdata.php?s=2&sid='+bb,
afterSubmit: function(server_data, posted_data) {
result = server_data.responseText.split(”;”);
//alert(result[1]);
if (result[0] == “success”)
return [true,"",result[1]];
else return [false,"Error inserting row"];
}
});
}
else {
alert(”Please select a school to add years to.”);
}
});
And this is the php used to update it:
“INSERT INTO `tblYears` (`Year_ID`,`Sch_ID`,`Year`) VALUES (NULL,'”.$_GET['sid'].”','”.$_POST['Year'].”')”);
I can get the script to insert the row into the database, but the problem is with the getSelectedRow function. When I click to Add a year the alert displays the correct ID for the school. This is fine the first time, but if I select a different school then click to Add, the alert displays the correct ID, but the bb variable still contains the previously selected School.
It appears that the ID parsed using bb is retained from selecting the very first school, all years will then be inserted into the first selected school.
Am I missing something here? I'm racking my brain trying to figure this out.
07:08

Moderators
30/10/2007

You do not need to do that. The id of the posted data is passed automatically. If you fave FireBug you can see what is posted.
Maybe you use 3.1 version. This bug is corrected in 3.2rc, but one user reported that there is a something wrong with the replacement (zip). Could you please use 3.2rc. In this case your code should work.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
07:17

27/06/2008

07:28

27/06/2008

07:46

Moderators
30/10/2007

Replace only grid.formedit.js - this should work
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
07:57

27/06/2008

I tried with the new grid.formedit.js with the same problem. It appears to be only be setting the url variable once. Adding an alert in just before the ajax call on line 273 of the new grid.formedit.js file shows the same url, even though this has changed in the editGridRow call in my jQuery(”#years”).editGridRow('new'... etc function.
08:09

Moderators
30/10/2007

This should work.
I recommend you to clear the cache. Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
08:13

27/06/2008

08:16

Moderators
30/10/2007

Check to see if you use the min version in jquery.jqgrid.js then replace the appropriate way
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
08:23

27/06/2008

I'm using the standard js files as i'm putting the following alert in grid.formedit.js (3.2rc):
271: // we add to pos data array the action - the name is oper
272: postdata.oper = postdata.id == “_empty” ? “add” : “edit”;
273: alert(url);
274: $.ajax({
The alert is displayed, but the url var is not updated, even though the parsed url has changed (url:'setdata.php?s=2&sid='+bb). Its like once it is set it cannot be changed?
08:47

Moderators
30/10/2007

Could you plese try this:
Just curios to see if this will work
$(”#addyear”).click(function(){
bb = jQuery(”#schools”).getSelectedRow();
alert(bb);
jQuery("#years").setGridParam({editurl: 'setdata.php?s=2&sid='+bb});
if( bb != null ) {
jQuery(”#years”).editGridRow('new',{
height:100,
width:200,
reloadAfterSubmit:false,
closeAfterAdd:true,
closeAfterEdit:true,
drag:true,
modal:true,
afterSubmit: function(server_data, posted_data) {
result = server_data.responseText.split(”;”);
//alert(result[1]);
if (result[0] == “success”)
return [true,"",result[1]];
else return [false,"Error inserting row"];
}
});
}
else {
alert(”Please select a school to add years to.”);
}
});
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
08:51

27/06/2008

09:01

Moderators
30/10/2007

Thank you.
I will investigate why url is not working. But it seems that a click event
have something to do in this case. I have a similar problem
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
76 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