jQWidgets Forums

jQuery UI Widgets Forums Grid Row count for addrow?

This topic contains 2 replies, has 2 voices, and was last updated by  onefortypoint6 12 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Row count for addrow? #18115

    onefortypoint6
    Participant

    I am trying to add a new row, using ‘addrow’; I am not able to find a solution to get the rowID of the last added row (added to the grid, but not inserted to the database yet).

    One possible solution is to take the current row count, add 1, then use that number when using ‘addrow’. Is there a way to get the current number of rows in a grid? Should I refer to the data adapter to get a row count?

    Is there a different/better approach of getting the rowID/index of the most recently added row?

    Row count for addrow? #18128

    Peter Stoev
    Keymaster

    Hi onefortypoint6,

    My suggestion is to synchronize your Grid with the DB in the “addrow” function of the source object. Make an ajax call to your DB for synchronization and return commit(true, rowID) if it is successful in the Ajax’s success callback. Otherwise, return commit(false) to cancel the UI changes. By calling commit(true, rowID) you confirm the UI changes and set a new ID of the UI row. On your server, you can return the new row’s id after inserting it in the DB. In case you want the Grid to auto-generate the ID of the UI row, you should pass null as a first parameter when you call the “addrow” method of jqxGrid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Row count for addrow? #18143

    onefortypoint6
    Participant

    Thanks Peter. Using I’m using addrow as a function from a button. (my grid has an ‘Edit’ button column for popup editing) When addrow completes from the ajax call and commits to the grid, how can I find the new row in the grid, then simulate clicking the Edit button?

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

You must be logged in to reply to this topic.