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
Detecting row changes
04/08/2009
15:15
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

I'd like to detect when a row's contents have changed so that I only have to make the round trip to the server when the actual data has changed.  Right now I have my code conditioned on onSelectRow but of course it will show me what the row contents on a prior row was (if I save them) and it will show me what the currently selected row is.  What I *want* is to compare the "before" and "after" values of the data on the same row.  Something conditioned on an "onLeave" or "on blur" event to capture the record after it has been changed.

Has anyone done something like this?  A nice enhancement would be to have an "onRowChange" event to fire when the contents have actually changed.

Ideas?

Thanks!

05/08/2009
02:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

There is a option savedRow, which save the row before editing. See options in grid.

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.

05/08/2009
17:06
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks Tony.  I can see the property but it doesn't appear to have a value.  I am using 3.4 of jqGrid.  Do you have an example of how to use this property?  In my case, I used it like this:

olddata = $('#myGrid').savedRow;

But there is no value in the property.  How/when does this get populated?

I create the grid, populating the grid from the DB.  Then, using inline editing, I would like to add some code to the onSelectRow function that basically compares the row as it was before the row was selected and the current value and, if there is a difference, THEN save it.  I don't want/need to save the row if it hasn't changed.  I am trying to detect that change.

If this is a 3.5 feature, let me know and I'll try it but it would also be helpful to see and example of how I would implement it.

06/08/2009
10:10
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

This is created for you automatically.

After editing the row - you can

var savedrow  = $("#mygrid").getGridParam('savedRow');

Regards

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.

06/08/2009
13:15
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Tony.  Thanks!  Of course. It's a *grid* parameter so getGridParam would be the method to return it.

Sigh!  Sorry to bother you.

06/08/2009
21:11
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

One more issue.  It looks like the  $(”#mygrid”).getGridParam('savedRow') method is returning an array of multiple rows.  Every time you save a row the savedRow parameter contains an additional rows information.  Is that the intended behavior? If so, perhaps you should rename the parameter to savedRows (plural) which would more accurately indicate that the parameter contains ALL saved rows, rather than the row *just* saved, which is what I would have expected.

Also, I want to pass the saved row to my server function as a parameter.  I know that the current row's data is passed as a parameter in the saveRow function but how would I change the savedRow parameter to a string that could be passed to the server?  I grab the last row in the savedRow array like this:

        var mySavedRow = $('#subQual').getGridParam('savedRow');
        var rownumsaved = mySavedRow.length - 1;
        if(rownumsaved >=0)
            var rowData = mySavedRow[rownumsaved];

but toString and JSON.stringify n the variable rowData return invalid results.  It appears to be an array but I can't quite coerece it into a string.

Ideas?

07/08/2009
00:42
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

You are right, but I think it is too late to change the name.

Do not know why this can not be converted. Check what you have in rowData

also you can do this

console.log(rowData);

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/08/2009
09:45
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

The wierdness is that Firebug shows that rowData looks like an array of values. rowData displays like so in Firebug:

- rowData

     certified=""

     criteria1="TEACH"

     criteria2="ANY"

     criteria3="RHS"

     criteria4=""

     criteria5=""

     gradeMax="12"

     gradeMin="09"

     id="3"

     preferredSeq=""

These are the values from the row that was saved so that IS correct, yet console.log(rowData) returns [ ] (empty array).

I'll experiment some more but if I can get this cast to a string, I can finish up this app.

Thanks

07/08/2009
10:18
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Yes it is a bug - Fixed in GitHub. Could you please let me known if all work OK.

Thanks

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/08/2009
18:05
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks Tony.  I came up with a temporary workaround but I'll apply the update and test it this weekend.

Much appreciated.

10/08/2009
10:55
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Tony, I am going to assume your changes were for the 3.5 version.  I compared your changes in 3.5 and noticed that you changed the svr parameter from svr=[] to svr={} .  I ported those changes to 3.4.4 and that seemed to fix the issue for me.

27/10/2011
21:21
Avatar
MANKOWITZ
New Member
Members
Forum Posts: 1
Member Since:
27/10/2011
sp_UserOfflineSmall Offline

Pete-

This seems like an elegant solution. Have you implemented it? Do you have example code?

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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