cancel
Showing results for 
Search instead for 
Did you mean: 

How To Delete a Row From a TableView !!!!

Former Member
0 Kudos

Hi,

Does any know how to delete a row from a table view model.

I have a TableViewModel being displayed, when the user select the particular row and click delete i want that particular row to be deleted.

Any Suggestions How.

Thanks,

Emmanuel.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

If u want to delete single row, then set the property of TableView - selectionMode="SINGLESELECT". Select the radio button and click on delete button. In the main program, you can get the row value like...

public void onDeleteButtonClicked(Event event) throws PageException {

TableView table = (TableView) this.getComponentByName ("idTableView");

DefaultTableViewModel dmodel = myBean.beanModel;

String pid = "", row_selected;

// Get the first visible row

int firstVisibleRow = table.getVisibleFirstRow();

// Get the last visible row

int lastVisibleRow = table.getVisibleLastRow();

for (int i = firstVisibleRow; i <= lastVisibleRow; i++) {

if (table.isRowSelected(i)) {

row_selected = i;

pid = dmodel.getValueAt(i, 1).toString();

}

}

}

"i" will give you the row no, pid has the value of the row at first column.

Hope this helps.

Thanks,

Praveen

Former Member
0 Kudos

I think you have to find out which row has been clicked, fetch the existing tableviewmodel and remove the row there, and then create a new tableview