I am adding a row, using: WebHierarchicalDataGrid1.get_rows().add(dataArray)
The row is being saved from a Single Record View that I developed. The requirement is that after the row is added, the person continues to work on the same row. However, I haven't figured out how to get reference to that newly added/inserted row, in order to make changes to its values. Also, I have paging enabled, so I can't just take the last row, because it gives me the last row on the first page, which doesn't help me if I have more than one page. But I had a few ideas.
- Does the add(dataArray) return any values? For example, if it could return the added row, that would be great.
- Could I disable paging for the grid from javascript, then get the last row, and enable paging again?
- I also tried <ig:EditingCore EditingClientEvents-RowAdded="WebHierarchicalDataGrid1_RowAdded">, but WebHierarchicalDataGrid1_RowAdded is not called at all for some reason. Just in case, I have a server eventhandler for rowadded too.
- Another method, I thought would do it, is to change the selected page from javascript, and then retrieve the last row on the page. Is that possible?
- Finally, if I don't find answers to these questions I'd probably just update the datasource itself instead of going through the grid CSOM.
I would highly appreciate your answer to these questions and a recommended way to handle my problem!
Thank you,
Arman
Hi Arman,
I want to let you know that I am looking into this issue for you and will have an update for you on or before Wednesday regarding this inquiry.
Thanks
I actually made it work changing the page selected index. It was a bit complicated, but here is how, if someone needs it:
1. After I add the row to the grid: WebHierarchicalDataGrid1.get_rows().add(dataArray), I return the id of a new inserted row from stored procedure, and receive it on SqlDataSource_Inserted, making a Session['new_id']=<id>.
2. Add <ClientEvents AJAXResponse="WebHierarchicalDataGrid1_AJAXResponse" /> and inside WebHierarchicalDataGrid1_AJAXResponsefunction I call PageMethods and on success return the new id from the Session, store it in the hidden field on the page and change the page selected index:
var pageCount = WebHierarchicalDataGrid1.get_behaviors().get_paging().get_pageCount(); WebHierarchicalDataGrid1.get_behaviors().get_paging().set_pageIndex(pageCount - 1);
and clear the Session variable using PageMethods, so that every async postback doesn't make the grid go to the last page.
3. After this, updating the row, I find the row by the new id and make changes to it.
Works for me.
Thanks,