cancel
Showing results for 
Search instead for 
Did you mean: 

How to select the entire row by selecting the checkbox in a table

Former Member
0 Kudos

Hi All,

In my application iam using one table having A, B columns

for this table i have to use checkboxes for every fields,

when i select checkbox , it should select the total row to get that field values.

this is my requirement. please experts help me on this.

here i want to know how to use checkboxes for a table to select a single row or multiple rows also

when i select multiple checkboxes multiple rows should select and it shud give values.

please help me out.

regards,

sush

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

HI sush,

You want to retrieve data against which you want to select

Value Node--Person

Value Atribute--A,B,C

for check box--C value attribute.

CTYpe-boolean.

one thing you can do--

int size=wdContext.nodePerson().size();

for(int i=0;i<size;i++)

{

if(wdContext.nodePerson().getPersonElementAt(i).getC()){

// then you will get your value.

//aslo you can set othe node...

wdComponentApi.getMessageManager().reportSuccsess("A"+wdContext.nodePerson().getPersonElementAt(i).getA());

wdComponentApi.getMessageManager().reportSuccsess("B+wdContext.nodePerson().getPersonElementAt(i).getB());

}

}

thanks

Jati

Former Member
0 Kudos

Hi,

In the layout, create a column using a checkbox as the tableCellEditor and then create a context element (say - rowCheckBox) in the table node of type boolean for the checkbox and bind this element to this context element.

Then in the controller in the action of the save button you need to write the following code :

public void save (){

// Declare an object of RFC and bind it

// if RFC name is ABD

ABD_input rfc = new ABD_input();

wdContext.nodeABD().bind(rfc);

for(int i =0; i< name of the table node ; i++){

if(wdContext.nodename().getNodeNameElementAt(i).getRowCheckbox()){

//declare an object of the structure and then set the value of the two columns in the structure fields //and then add the structure to the import parameter of table type.

TableStructure ts = new TableStructure (); // the table is of type TableStructure

ts.setColA();

ts.setColb();

rfc.addSaveRows(ts); // SaveRows is the name of the internal table.

}

}

try{

wdContext.currentABDElement().modelObject().execute();

wdContext.nodeABD_Input().outputnode.invalidate();

}catch(Exception e){

}

}

Hope this answer you to solve the problem.

Thanks

Ritushree Saha

Former Member
0 Kudos

Hi ,

As, you might have got the solution from above post's.

I want to add little more information to help you to design your UI.

UI inside UI will increase your overhead time. Screen rendering will take some time.

If still you want to go for checkbox in table then.

create a value node i.e. Empdetails.

now create value attributes say --> name , add, tele and CheckBoxSelected (it's a boolean variable).

Add this context node to table.

Set CheckBoxSelected = false (as default value).

Bind CheckBoxSelected to CHECKED property of checkbox.

Now, you can write your logic to access selected checkbox.

Or you can take help of following code.

for(int i = 0; i < wdContext.nodeEmpdetails().size(); i++)

{

wdContext.nodeEmpdetails().moveTo(i);

if(wdContext.currentEmpdetails().Element().getCheckBoxSelected())

{

/* Write your logic

}

}

Please correct me if i am wrong.

Regards

Abhijeet

Former Member
0 Kudos

I don't understand this: Why do you need to select a table row "to get that field values"? What does that mean?

Armin

Former Member
0 Kudos

Hi Armin,

here i want to select the rows of a table ,

for example in my table i have 5 rows among them i want to select 2 rows

in my application iam using checkboxes in a table so by selecting checkboxes , the corresponding rows values should come this is my exact requirement.

here i want to know how to use checkboxes for a table to select a single row or multiple rows also

when i select multiple checkboxes multiple rows should select and it shud give values.

regards,

sush

Former Member
0 Kudos

Hi sushama,

There is no need to create an extra column with check box in the table to select muliti rows. U can do that by settting the selection mode property of the table to multi selected.

int size = wdContext.node<name>().size();

int leadSelection = wdContext.node<name>.getLeadSelection;

for(int i=0; i<size; i++)

{

if (wdContext.node<name>().isMultiSelected(i) || leadSelected == i)

{

I<node name>Element ele = wdContext.node<name>().get<Attribute>ElementAt(i);

// now get the attributes of the element ele and set it to the desired node element.

}

}

please refer this link for more.

[;

If u still want to go ahead with the check box requirement, please let me know i will help u out..

Jithin

former_member185086
Active Contributor
0 Kudos

Hi

Follow this procedure..

1. Create one action for check box

2. In this way any two row will be selected.

for (int i = 0; i < 2; i++)
		{
			wdContext.nodeTestNode().setSelected(i, true);
		}

3. Set Node cardinality 0..n

4. Further , if want to put certain condition then u can in this code.

Best Regards

Satish Kumar

pravesh_verma
Active Contributor
0 Kudos

Hi Sush,

It seems you want to simulate the functionality which SAP EP screens use to have in it initial releases. Where whenever the user clicks on the check box the entire row is selected. However just to inform you, SAP has now shifted to a standard of multiselection of rows by just clicking the row number.

You can do the selection as well as multiselection of rows without even having the checkboxes.

Well if that is the requirement is to do it using the checkbox only then you can follow these steps:

1) Create the checkbox as the cell editor of your column 1

2) Create and bind a action to the toggle event.

3) Go to the action tab of View designer and add parameters to the action which you have binded to the checkbox.

Add following parameters:

1) Checked -- Datatype: boolean

2) nodeElement -- Datatype: I<NodeName>Element.

Now click on the layout --> Right click on the checkbox UI element from the Outline pane -> Click on Parameter mapping.

Do the mapping of the parameter checked and nodeElement by dragging the parameter to the Action.

By this you will complete the process of parameter mapping.

Now in the event method of check box where you want to know the selected row details, use this code:



int roeNumber = nodeElement.index();
String val1 = nodeElement.get<AttributeName>();

I hope this helps and solves your issue. Please revert back in case you want any further help.

Thanks and Regards

Pravesh

Former Member
0 Kudos

I recommend to use the Table UI element selection as designed and not adding a column of check boxes. Just set the selection cardinality of the data source node to 0:N and everything works out-of-the box. You can then select multiple rows with CTRL-Click.

Armin