Query regarding inserting a new row at first row data table
hi all,
I have a doubt regarding the insertion of new row in data table.I am now using the following code
if (skillDataProvider.canAppendRow()){
RowKey rowkey = skillDataProvider.appendRow();
skillDataProvider.setCursorRow(rowkey);
String skillID=getSkilID();
skillDataProvider.setValue("Skill.SkillID", rowkey, skillID);
int rowID=Integer.parseInt(rowkey.getRowId());
tableRowGroup1.setFirst(rowID);
}
Its working fine.But this code gives me provision to add the data at the last of the table.I need it to be at the first row.I tried
RowKey rowkey=skillDataProvider.insertRow(skillDataProvider.getRowKey(String.valueOf(0 )));
but it shows some null pointer exception.Can anyone help me?
Thanks in advance
Sree
[801 byte] By [
harisree] at [2007-11-26 9:07:16]

# 4
hi daniel,
Thanks for the reply.I tried with that also.But it is not working.Can we use insertRow() for this.What i meant is
dataprovider.cursorFirst();
RowKey firstRow=dataprovider.getCursorRow();
RowKey rk=dataprovider.insertRow(firstRow);
But this returns a Null rowKey.Do you have any solution for this?Please help me
Thanks in advance
Sree
# 7
I think AChervov has the right idea here.
CachedRowSetDataProvider.canInsertRow(beforeRow) returns false, so you cannot insertRow().
Therefore, you'll need to control the sort order yourself. I'd add a sort field to the database. Then use TableRowGroup.setSortCrtieria() to control the table display order. Or commit the append to the database immediately and reselect (refresh) the provider (assuming the provider has the desired "order by").
# 8
I am having the same problem, and I am pretty sure my problem doesn't relate to databases and their order, because my datatable is bound to a List, not directly to a table, and I get that List from Hibernate query. What should I do in order to get this working? It's really driving me