Skip to Content
avatar image
Former Member

Check Box in a table

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Jul 07, 2009 at 08:00 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 08, 2009 at 04:31 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 08, 2009 at 05:28 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 08, 2009 at 06:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 08, 2009 at 06:22 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 08, 2009 at 11:24 AM

    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

    Add comment
    10|10000 characters needed characters exceeded