cancel
Showing results for 
Search instead for 
Did you mean: 

Check Box in a table

Former Member
0 Kudos

Hi,

I want to have a checkbox in one of the column in the table. When this checkbox is selected, then I need to pass this value is selected to the backend. How can we do this?

How we can have some action when the checkbox is selected?

Regards

MQ

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

You need to follow these steps to get the checked value on submit and pass it to the backend :

1. create one value attribute (let us suppose name is flag) of type boolean in the node to which the table is bound.

2. In the table, now add the checkbox UI element and bind the flag to that "checked" property of check box UI element.

3. Now create one Action onSelectAction

4. Add this action to the "onSelectAction" porperty of check-box.

5. Create another node to add the selected data to the node.

In onSelectAction write the code to read the checkbox value.

Now in the code you can get the selected rows by user as below:

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

{

boolean isSelected = wdContext.current<table_node>.getTableNodeElemntAt(i).Element.getFlag();

if(isSelected)

{

IPrivateTestView.IResultNode element=wdContext.createResultNodeElement();

element.setAtt1(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt1());

element.setAtt2(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt2());

wdContext.nodeResultNode().addElement(element);

}

}

Hope this solution helps you.

Thanks

Ritushree

Former Member
0 Kudos

Hi,

Refer this code,

Create a boolean attribute select in the table node and bind it to checked property of the check box.

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

{

if(wdContext.node<tablenode>().get<tablenode>ElementAt(i).select())

wdContext.node<tablenode>().get<tablenode>ElementAt(i).set<yourattribute>("X");

else

wdContext.node<tablenode>().get<tablenode>ElementAt(i).set<yourattribute>(" " ");

}

Regards,

Sunaina Reddy t

Former Member
0 Kudos

Hi,

In the Node which you binded to the table create one more attribute of type boolean.

For example your node is as below:

//Table Node

TableNode

-


> Att1

-


> Att2

-


> isSelected(boolean) - Newly created attribute for this requirement.

//Result Node contains the elements selected in TableNode

ResultNode

-


>Att1

-


>Att2

Now in the table create one more Column with Checkbox as tablecell editor.

Now bind this "isSelected" boolean attribute to that "checked" property of check box UI element.

Now in the code you can get the selected rows by user as below:

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

{

if(wdContext.nodeTableNode().getTableNodeElementAt(i).getIsSelected()==true)

{

IPrivateTestView.IResultNode element=wdContext.createResultNodeElement();

element.setAtt1(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt1());

element.setAtt2(wdContext.nodeTableNode().getTableNodeElementAt(i).getAtt2());

wdContext.nodeResultNode().addElement(element);

}

}

Regards,

Charan

Former Member
0 Kudos

Hi ,

Lets assume that your table node of this structure

Table -- Node

|

|-- Check -- Value attribute of type 'boolean'.

Now you have a button on click which you want to save the selected rows. The selected rows now will contain the value of attribute 'Check' as 'true'.

OnClick - Event handler

wdContext.nodeTable().moveFirst();

for (int i=0;i<wdcontext.nodeTable().size();i++)

{

if(wdcontext.currentTableElement().getCheck()

{

//Save your data to backend

}

wdContext.nodeTable.moveNext();

}

Best Wishes

Idhaya R

Former Member
0 Kudos

Hi,

To add a check box in your table follow these steps:

1. create one value attribute (let us suppose name is BooleanVal) of type boolean in the node, which you bind to the table.

2. In the table, expand the BooleanVal column and delete the TextView element from that. Add the checkbox UI element and bind the BooleanVal to

3. Now create one Action onToggleBooleanValAction.

4. Add this action to the "onToggle" porperty of check-box.

In onToggleBooleanValAction write the code to read the checkbox value.


boolean isSelected = wdContext.current<table_node>Element.getBooleanVal();

Hope this helps!

Regards,

Jaya.

Former Member
0 Kudos

Hi

In check box you have onToogle Action.

You can call an action Handler of this Action to execute some logic in backend.

Regards

Marcos