jQWidgets Forums

jQuery UI Widgets Forums Grid Which event occurs first ? Delete row or update row?

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 11 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • reggaeone13
    Participant

    I have a grid with status bar and on this are Add, Delete and Refresh buttons (all with implemented methods).
    The first visible column has columntype: ‘combobox’ and the grid has selection mode ‘singlerow’.
    To make possible to delete a displayed row, a row must be at first selected. So, when I select a row by clicking the first cell of that row, the editor of that cell (combobox type is ‘combobox’) will be open.
    What is expected to be done at first, when a click on Delete button from status bar (of course with confirm popup window) will be called? The ‘deleterow’ method (deleteButton.bind(‘click’, function () { … ajax call … });) or the ‘updaterow’ method?
    Currently the ‘deleterow’ method works, but an update of the selected row ends with delete of that row.

    What I am doing wrong here?

    Source object has only updaterow: function (rowid, rowdata, commit) { … ajax call …}, and $(“#jqxgrid”).bind(‘cellendedit’, function (event) { … var commit = $(“#jqxgrid”).jqxGrid(‘updaterow’, rowindex, rowData); });

    Please help!
    Thanks a lot!


    Peter Stoev
    Keymaster

    Hi reggaeone13,

    When you call “deleterow” the “deleterow” callback of the source object will be called, if it is defined. When you update a row via “updaterow” method of jqxGrid or by editing a cell from a row, the “updaterow” will be called. These are 2 different methods with 2 different functions.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    reggaeone13
    Participant

    Hi,

    first of all thank you very much for the answer.

    Please, I have another question regarding updaterow method.

    Conform documentation “Editing (requires jqxgrid.edit.js)” and Code example

    Invoke the updaterow method

    // @param row id. Use the ‘getrowid’ method to get the id of a row.
    // @param row data. The expected value is a JSON object.
    var value = $(‘#jqxGrid’).jqxGrid(‘updaterow’, rowid, newdata);

    Can the JSON object be empty as Response from Server, when some of the row’s cells are empty, because the row is blank?

    What is expected as JSON object, when a blank row was added and an update command is send to Server?

    Please, I need this help!

    My jqxGrid cannot be updated in the database!
    In this situation I must Abort this Project, because it make not sense to have a pretty coool jqxGrid without update to database!

    Thank you very much in advance!


    Peter Stoev
    Keymaster

    Hi reggaeone13,

    The Grid’s updaterow method updates a Visual Row in the Grid and this method calls the source object’s “updaterow” callback if it is defined. In the “updaterow” callback, you should implement the synchronization with your Server. That is not done by the Grid as it does not know about your Server and Database. The “updaterow” callback of the source object gets passed 3 parameters – the row ID, the updated row’s data and a commit callback function. If your synchronization with your Server is OK, call commit(true). If it fails, call commit(false) to decline the UI update. I also suggest you to look at the CRUD samples in the help documentation.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.