Adding row to a ListGrid at a specified index Smart GWT

463 views Asked by At



Currently I'm working on a listgrid which is editable and my requirement is to create a a new row every time a user selects a row and presses the "Create" Button. The new row needs to be added immediately below the selected row. I tried using the below method

ListGrid.getRecordList().addAt(ListGridRecord rec, Index index)

However I got the warning message

15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.

I've searched the smartgwt showcase to look for ways to edit a grid , so that new row is added at a specified index, however I wasn't able to find anything suitable.

I got to know that ResultSets is getting created because I'm using the statement ListGrid.fetchData() Is there any way to solve this issue? Any suggestion is highly appreciated!

Muchas Gracias.

1

There are 1 answers

0
Mayank Shekhar On

Figured it out, quite a weird trick...but works for me... what you need to do is use grid.setRecords(grid.getRecords()); just before grid.getRecordList().addAt(rec, index); I think doing this makes the ResultSet editable.