TableViews are backed by an instance of List. You can get access to each of the
beans to delete via the get() method, which takes an integer index.
On Nov 3, 2011, at 3:08 AM, V SANTOSH PAVAN RAJU BS wrote:
> I have created a TableView and added rows using a Bean class and inserted
> column entries dynamically, which were saved in database.
> I the same wa i need to delete selected rows in the database. So i need to
> get the selected row index and capture one of the column entry for that
> particular row, by this i can execute my sql command to delete complete row
> in database. For this i have used the following code:
>
> deleteButton.getButtonPressListeners().add(new ButtonPressListener() {
>
> public void buttonPressed(Button button) {
>
> int first = tableView.getFirstSelectedIndex();
> int length = tableView.getLastSelectedIndex() -
> first + 1;
> tableView.getTableData().remove(first, length);
>
> String code = accounts.getCode();//accounts is
> the Bean class instance.
> String name = null; //getCode().getName(),getType(),etc.. are the
> getterMethods in BeanClass
> String type = null;
> String taxRate = null;
> String accBalance = null;
>
> accounts = new AllAccounts(code, name, type,
> taxRate, accBalance);
> IAccountDao dao = new AccountDaoForDelete();
> if(dao.accountValid(accounts)){
> Alert.alert(MessageType.INFO, "Deleted
> Successfully......", AccountDB.this);
> }
> else
> Alert.alert(MessageType.INFO, "Please
> try again...", AccountDB.this);
> }
> });
>
> here the first inserted row was deleted successfully in DB. But while trying
> to delete the remaining rows nothing is happening..
> Here i understood that i need to get columns based on selected row entries.
> How can i get them based on selected index.............
>
> --
> Thanks & Regards
> B.S.V.S.Pavan Raju.
> Skype: skype_pavan1
> Hyderabad.
>