jQWidgets Forums

jQuery UI Widgets Forums Grid what's the point of "var commit = …"

This topic contains 4 replies, has 2 voices, and was last updated by  suall936 9 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • what's the point of "var commit = …" #75127

    suall936
    Participant

    Hi,

    I found this code in the example of jqGrid:

    var commit = $(“#jqxgrid”).jqxGrid(‘deleterow’, id);

    Does it has anything to do with the commit callback function? And what is the return value of ‘deleterow’ method, it returns false when delete succeed which is a bit strange.

    Thank you.

    what's the point of "var commit = …" #75136

    Mariya
    Participant

    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,
    Mariya

    jQWidgets Team
    http://www.jqwidgets.com

    what's the point of "var commit = …" #75196

    suall936
    Participant

    Hi 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

    what's the point of "var commit = …" #75201

    Mariya
    Participant

    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,
    Mariya

    jQWidgets Team
    http://www.jqwidgets.com

    what's the point of "var commit = …" #75208

    suall936
    Participant

    Hi 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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.