[Trinidad] Not able to delete a record after sorting the table column

View: New views
2 Messages — Rating Filter:   Alert me  

[Trinidad] Not able to delete a record after sorting the table column

by Glen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Design : Trinidad table component with attribute rowselection=multiple.
Functionality: Delete a selected row after sorting any column.
Logic/Implemention: Getting RowData for the selected rowKeySet using
table.getRowData(Integer.parseInt(selectedRowKeys.next().toString())) 
Issue: Here getting a different value for the selectedRowKeys.next() , rather than the selected row.
Observation: After sorting, rows data are getting sorted but the row keys (table index) remains in the same order (0,1,2,3...) where we are using for deleting the selected rows.

Please Provide the solution for the above issue.
Or any alternative for deleting a table row with Rowselection=multiple

Thank You

Re: [Trinidad] Not able to delete a record after sorting the table column

by Marco Grimm :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Implement your own CollectionModel class (e. g. MySortableModel extends SortableModel) with getRowKey() and setRowKey(Object) methods e. g. like the following:

        @Override
        public Object getRowKey() {
                return isRowAvailable() ? getRowData() : null;
        }

        @Override
        public void setRowKey(final Object key) {
                if (key == null) {
                        setRowIndex(-1);
                        return;
                }
                for (int i = 0; i < getRowCount(); i++) {
                        setRowIndex(i);
                        if (getRowData().equals(key)) {
                                break;
                        }
                }
        }

Then instantiate this MySortableModel and provide the tr:table sortableModel attribute with this instance.

Glen wrote:
Design : Trinidad table component with attribute rowselection=multiple.
Functionality: Delete a selected row after sorting any column.
Logic/Implemention: Getting RowData for the selected rowKeySet using
table.getRowData(Integer.parseInt(selectedRowKeys.next().toString())) 
Issue: Here getting a different value for the selectedRowKeys.next() , rather than the selected row.
Observation: After sorting, rows data are getting sorted but the row keys (table index) remains in the same order (0,1,2,3...) where we are using for deleting the selected rows.

Please Provide the solution for the above issue.
Or any alternative for deleting a table row with Rowselection=multiple

Thank You