cancel
Showing results for 
Search instead for 
Did you mean: 

Deletion of selected rows in WD Java table

Former Member
0 Kudos

Hi Experts,

We have a requirement to select (Using check box as a TableCellEditor to select the rows) any row (Single OR multiple) in a WebDynpro java table and to remove the selected rows from the table on action (Button).

Data come from BAPI and we are using Value Node as a Data Source for this table. Our NWDS version is 7.01.

Please suggest appropriate method to achieve the same.

Thanks and Regards,

Ghanshyam Agarwal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ghanshyam..

Create an attribute(Boolean) at table level node (0..n).

and create one action for delete selected rows. and put below code..

*************************

IPublicVcTrgCrtOrdComp.I<your value node>Element element;

      for(int i = 0; i< wdContext.node<your value node>().size();i++)

      {

       element = wdContext.node<your value node>().get<your value node>ElementAt(i);

    

       if(element.get<selected attribute>() )

       {

        wdContext.node<your value node>().removeElement(element);

        i = i-1;

       }

   

      }

********************************

Thanks & Best Regards

Aasif Shah

Former Member
0 Kudos

Great

It seems to be working fine now. Thanks for your helpful inputs.

I need one more input. I have to display a message to user on the action if none of the rows have been selected "Please select a row to remove". Please help.

Former Member
0 Kudos

update your code with below code

******************************************************************************************

IPublicVcTrgCrtOrdComp.I<your value node>Element element;

int selectedRows = 0;

      for(int i = 0; i< wdContext.node<your value node>().size();i++)

      {

       element = wdContext.node<your value node>().get<your value node>ElementAt(i);

    

       if(element.get<selected attribute>() )

       {

     selectedRows= selectedRows+1;

        wdContext.node<your value node>().removeElement(element);

        i = i-1;

       }

   

      }

if(selectedRows == 0)

{

wdComponentAPI.getMessageManager().reportException("Please Select any record for delete");

}

Former Member
0 Kudos

Resolved.

Thanks Aasif.

Former Member
0 Kudos

Welcome Always....

Regards

Aasif Shah

Answers (1)

Answers (1)

former_member191044
Active Contributor
0 Kudos

Hi Ghanshyam,

can't you just add a boolean attribute to the node and bind a checkbox to it in the table? Then you could loop over the node entries and delete the checked ones.  I don't know the possibilities of 7.01 so i can't exactly tell you the solution.

Regards,

Tobias

Former Member
0 Kudos

Hi Tobias,

I have already added a boolean attibute to the node and assigned it to the chckebox. I have tried a for loop in on action code to get the selected rows but its picking only the first row and the rest of the rows remain unselected even after clicking on the checbox. I need to delete all the selected rows.

Please suggest.

former_member191044
Active Contributor
0 Kudos

Could you please post your deletion code? So i will check it and maybe help you with it.

Former Member
0 Kudos

Please find the code below for your reference.

     boolean select = wdcontext.node<node_name>.current<node>Element.getCheckBox();

     int nodeLength = wdcontext.node<node_name>.size();

     for(int i=0; i<nodeLength; i++){

         

          if(Select){

                   wdcontext.node<node_name>.removeElement(wdcontext.node<node_name>current<node>Element());     }

}