In some of case you may want to insert a new row at the end of the table then this method will come handy.
public String CreateInsert() {
(DCIteratorBinding)bindings.get("EmployeeView1Iterator");
Row newRow = dcIterBind.getViewObject().createRow();
newRow.setNewRowState(Row.STATUS_INITIALIZED);
ViewObject vo = dcIterBind.getViewObject();
vo.last();
// to insert row at the end of the table
vo.next();
vo.insertRow(newRow);
return null;
}
public String CreateInsert() {
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();DCIteratorBinding dcIterBind =
(DCIteratorBinding)bindings.get("EmployeeView1Iterator");
Row newRow = dcIterBind.getViewObject().createRow();
newRow.setNewRowState(Row.STATUS_INITIALIZED);
ViewObject vo = dcIterBind.getViewObject();
vo.last();
// to insert row at the end of the table
vo.next();
vo.insertRow(newRow);
return null;
}
This comment has been removed by the author.
ReplyDeleteAnother way to achieve the above functionality is as follows :
ReplyDeleteDCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VOIteratorName");
if(dciter != null){
System.out.println("VO IS NOT NULL...");
}
else{
System.out.println("VO IS NULL....");
}
RowSetIterator rsi = dciter.getRowSetIterator();
//get handle to the last row
Row lastRow = rsi.last();
//obtain the index of the last row
int lastRowIndex = rsi.getRangeIndexOf(lastRow);
//create a new row
Row newRow = rsi.createRow();
//initialize the row
newRow.setNewRowState(Row.STATUS_INITIALIZED);
//add row to last index + 1 so it becomes last in the range set
rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
//make row the current row so it is displayed correctly
rsi.setCurrentRow(newRow);
Thanks for alternate method, I will test and update
ReplyDelete