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
Inline Editing: Re-Organize postData
27/04/2012
21:07
Avatar
brandonkirsch
Ohio
Member
Members
Forum Posts: 9
Member Since:
27/04/2012
sp_UserOfflineSmall Offline

Hello everyone,

First off, I would like to say thank you for such a great utility and its permissive MIT licensing.  JQGrid is a fantastic & mature collection and I am happy to add it to my toolkit.  However, I think there is room for improvement – specifically in the new inlinedit.js plugin for inline editing.

Currently, the inlinedit plugin has a "saveRow" method that collects the current set of row data and builds an object of {$columnName : $value, …}  But after it is done processing all of the columns, it then adds in {'id' : $rowID, 'oper' : 'edit'} to the same object for AJAX POST.  This presents a name collision for SQL tables that have columns named "id" or "oper" that is not easy to cleanup using the serializeRowData() event handler.

I think the inlinedit.js plugin would be better off if the postData was altered to look more like this:

 

  'request' : {

       'id' : $rowID,

       'oper' : 'edit'

  },

  'rowData' : {

        'colName1' : value1,

        'colName2' : value2,

        'id' : someOtherIDValueFromGrid,

        'oper' : someOtherOperValueFromGrid

  }

}

This way, "internal" jqGrid variables like "id" and "oper" do not collide with any fields that happen to have the same name.

I am working on a patch to grid.inlinedit.js to enable proper separation of request variables, but I am worried that the improvements will be lost in future versions of jqGrid.  Is there any chance that you would consider accepting these modifications when they are complete?

Thank you.

-Brandon

27/04/2012
22:22
Avatar
brandonkirsch
Ohio
Member
Members
Forum Posts: 9
Member Since:
27/04/2012
sp_UserOfflineSmall Offline

Here is the diff output of my completed patch.  It doesn't work 100% as described above, instead it simply puts all of the grid row data into a new property called "rowdata".  So the postData request object looks like:

{

 'oper' : 'edit',

 'id' : $rowID,

 'rowdata' : {

  // built exactly like parent object, except does not contain "oper" or "id" unless they are actually columns on the grid.

 }

}

Then a small change in the call to "setRowData" under saveRow -> $.ajax -> complete() handler to pass in tmp.rowdata instead of tmp.

The patch works and doesn't appear that it should cause any conflict with other parts of the plugin or jqGrid itself.  However, I cannot paste the "diff" output here so I will try to find a way to submit the patch on github.

EDIT:  Patch was updated to try and maintain backwards compatibility with existing client or server-side scripts that expect `tmp` to contain {fieldName : value} for all columns in the grid.

Patch is available at https://github.com/brandonkirsch/jqGrid/blob/master/js/grid.inlinedit.js

Thanks,

Brandon

28/04/2012
20:44
Avatar
brandonkirsch
Ohio
Member
Members
Forum Posts: 9
Member Since:
27/04/2012
sp_UserOfflineSmall Offline

I have found other (better) ways to accomplish the separation of request variables without modifications to JQGrid.

First, the 'prmNames' option can be used to adjust all JQGrid request parameters.  I have used this to prefix all variables into their own "jqgrid_" namespace, so to speak.

Second, I have adjusted my colModel to prefix each of my column names with "row_" and that allows me to separate request variables during server side processing.

JQGrid options are flexible enough to meet all of my needs, no modifications needed.  Thanks again!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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