Wednesday, July 29, 2015

ADF : Insert Row at the Top and Bottom of table

To insert row at the bottom of table follow followings steps:

Step 1 -  Generate VOimpl class of your  View Object.

Step 2 - Go to VOimpl class and add below code

         /**
     * Insert new Rows at the end of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the end of Rowset if it has rows
        Row lastRow = this.last();
        if (lastRow !=null){
             //insert new row at the end and make it current
            int indx = this.getRangeIndexOf(lastRow)+1;
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at bottom of table.


To insert row at the top of table follow following steps:

Step 1 - Generate VOimppl class of your View Object.

Step 2 -Go to VOimpl class and add below code,

         /**
     * Insert new Rows at the top of RowSet.
     * @param row
     */
    @Override
    public void insertRow(Row row) {
        //go to the First of Rowset if it has rows
        Row firstRow = this.first();
        if (firstRow !=null){
             //insert new row at the top and make it current
            int indx = this.getRangeIndexOf(firstRow);
            this.insertRowAtRangeIndex(indx,row);
            this.setCurrentRow(row);
        }else { // empty Rowset
        super.insertRow(row);
        }
        }

In this way row always insert at top of the table.


No comments:

Post a Comment