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
getSelectedRow parsing incorrect values?
27/06/2008
06:57
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

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.

27/06/2008
07:08
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/06/2008
07:17
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

Thanks Tony, i'll try 3.2rc.

The only reason i'm doing this is because the Sch_ID is from a different table and from what I gather you cannot override the parsed ID (which is "_empty" because its on adding a new record.

Awesome product though, makes admin update/edit/delete functions alot easier!

27/06/2008
07:28
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

I still seem to get the same problem after upgrading to 3.2rc 🙁

27/06/2008
07:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/06/2008
07:57
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

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.

27/06/2008
08:09
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/06/2008
08:13
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

On both occasions the url parsed to Ajax does not change.

I've cleared cache and tried different browsers (opera, FF).

27/06/2008
08:16
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/06/2008
08:23
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

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?

27/06/2008
08:47
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

27/06/2008
08:51
Avatar
mahers
Bundaberg, Australia
Member
Members
Forum Posts: 11
Member Since:
27/06/2008
sp_UserOfflineSmall Offline

That works!

Thanks for the workaround.

27/06/2008
09:01
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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