cancel
Showing results for 
Search instead for 
Did you mean: 

Checkbox Delete row

Former Member
0 Kudos

Hi,

I have a table with first column's TableCelleditor as check box. When I tick on check box ( one or many) and when I click on Delete Button, I want that selected row or rows to get deleted.

I have created a node for that table and in that node i have created a value attribute as chkbox with type as boolean. I have bind chkbox context to checkbox column.

Following is the code for delete button:

int checkTableSize = wdContext.nodeDrafts().size();

wdContext.nodeDrafts().moveFirst();

for(int i = 1; i <= checkTableSize; i++)

{

boolean value = wdContext.currentDraftsElement().getChkBox();

if(value)

{

wdContext.nodeDrafts().removeElement(wdContext.nodeDrafts().getElementAt(i));

}

The problem is that am not able to delete the row.

Can anybody help me in this case.

Regards,

Vaibhav

Accepted Solutions (1)

Accepted Solutions (1)

former_member182374
Active Contributor
0 Kudos

Hi Vaibhav Khairnar,

Try something like this:

int checkTableSize = wdContext.nodeDrafts().size();

wdContext.nodeDrafts().moveFirst();

for(int i = <b>0</b>; i <= checkTableSize; i++)

{

boolean value = wdContext.currentDraftsElement().getChkBox();

if(value)

{

wdContext.nodeDrafts().removeElement(wdContext.nodeDrafts().getElementAt(i));

<b>checkTableSize--;

i--;</b>

}

It's better to use while than for because you change 'i' in the process.

Omri

Former Member
0 Kudos

Hi,

Thanks for quick reply, The row is getting deleted but when I refresh the screen, the row appears again.

former_member182374
Active Contributor
0 Kudos

Hi Vaibhav Khairnar,

By 'refreshing the screen' do you mean your application is running again?

If the method that fills the table is executed when you refreshing the screen then you'll see it in the table...

Omri

Former Member
0 Kudos

Hi,

But what i want is that after deleting even if i refresh the screen or fill the table then deleted row should not appear.

former_member182374
Active Contributor
0 Kudos

HI Vaibhav Khairnar,

I guess the problem is the place you put the code that fills the table.

'wdDoInit' runs only once so if you'll fill the table in this method and then push the delete button the table won't be filled again.

Hope it helps,

Omri

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

i guess whenever the code for deleting row is executed , also the code for filling table is getting executed, so remove table filling code from here and write either in init method or write in some component controller or some custom controller

hope it helps

regards,

abhijeet

Former Member
0 Kudos

Hi Omri Cohen,

Thanks a lot for your reply. Am not filling table in this method. But when I refresh the portal, the deleted row reappears in table which should not happen since it is deleted from record (R/3).

former_member182374
Active Contributor
0 Kudos

Hi Vaibhav Khairnar,

I'm a bit confused here.

Deleting the row from the table will delete in from GUI only.

If you want to delete it from the backend, your 'delete' button should run RFC which actually deletes the record in addition to 'removeElement'

Omri

Former Member
0 Kudos

Hai,

You are fetching data from backend and put in context node ,display in table.

but you are deleting in context node only . when you refreshing the view it will fetch data from backend and put in context .

so delete from context as well as backend.

regards,

naga

Answers (2)

Answers (2)

monalisa_biswal
Contributor
0 Kudos

Use following method.

int checkTableSize = wdContext.nodeDrafts().size();

for(int i = checkTableSize-1;i>=0; i--)

{

//To check which row has been checked. Dont use Current element. It will always return lead selected row

boolean value = wdContext.nodeDrafts().getDraftsElementAt(i).getChkBox();

if(value)

{

wdContext.nodeDrafts().removeElement(wdContext.nodeDrafts().getElementAt(i));

}

}

abhijeet_mukkawar
Active Contributor
0 Kudos

hi ,

whatever code you have written for deleting row , write that in button click action,

and if it is already there then check if there is other code which helps filling the data into the table .

regards,

abhijeet