Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to add a row to the beginning of a listgrid?

    Hi,

    We are using Isomorphic smartclient version 5.6 for our application. We have a requirement in which a user can add a new row to the listgrid in the following ways

    1) Click on a button which opens a dialog and the user enters the data which gets added to the listgrid in the parent screen.

    2) The user can add a row by clicking on the first row in the Listgrid which says "Click here to add a new row." When clicked, the first row becomes editable and the user saves the record.

    In both the above cases, the row gets added to the end of the listgrid. This will be a problem if it involves pagination as the user will have to scroll to the last page to see the newly added row.

    Is there any way in which we can get the newly added row as the first row in the listgrid so that the user will know that the row is added ?

    Any help would be appreciated!

    Thanks,
    Karthik

    #2
    Hi kar_think,

    The simplest thing is probably to scroll to the bottom (use grid.body.scrollTo()) when a new row is being added. In order to add a new row at the top, you would actually use dataSource.addData() to add a new record, and ensure that it's values will cause it to sort to the top.

    In terms of managing this new record on the backend, you have two options:

    1) actually create a new, persistent row or object, but mark it as "inactive" in some way until the user has filled in enough fields to make it valid. SmartClient will submit changes to the record as a DataSource "update", exactly as for any other record

    2) don't actually create new, persistent row, but ensure your server code responds to SmartClient's requests exactly as though that new record was actually in the dataset. For example, on the "add" DSRequest that is triggered by your dataSource.addData() call, you would return the record-as-saved exactly as you currently do when a new record is really created in the persistent store. You would supply a temporary value for the primaryKey (keep in mind this must be unique as usual). You would only actually save the new record to your persistent store when you received an "update" request that fills in all required fields.

    Comment

    Working...
    X