jQWidgets Forums
jQuery UI Widgets › Forums › Grid › what's the point of "var commit = …"
Tagged: commit delete deleterow
This topic contains 4 replies, has 2 voices, and was last updated by suall936 9 years, 8 months ago.
-
Author
-
Hi suall936,
The jqxGrid’s method ‘deleterow’ deletes a row or multiple rows and it returns a boolean value if you are using a Local data. When you call the deleterow method, the Grid will also call the source object’s deleterow callback function(if defined). You can use that callback function for server synchronization.So commit is used as a callback function.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
Thank you for your reply. Sorry I didn’t make my question clear, I’m looking at the example from: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/createremoveupdatedata.htm
What I don’t understand is this part, the last line clears a variable called “commit” which seems never used after. What’s the point of doing this?
$("#deleterowbutton").on('click', function () { var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex); var commit = $("#jqxgrid").jqxGrid('deleterow', id); } });
Thank you
Hi suall936,
I am explaining the same example so your question was clearly asked.Commit is used as a callback function. With the callback functions you are synchronizing with the server.
var commit
is showing that the function is returning result in the example. It is not necessary to use it in your examples.Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHi Mariya,
Thank you for your explanation. I was thinking variable “commit” has something to do with the callback “commit”.
Now it’s clear.
Thank you.
-
AuthorPosts
You must be logged in to reply to this topic.