cancel
Showing results for 
Search instead for 
Did you mean: 

Easy Question: How to create Check boxes for table coloumn

Former Member
0 Kudos

Hi Experts,

I have created one WD Project. The project fetches some records from the R/3 using RFC. The output is in form of a table.

I have to provide check boxexsfor each coloumn. I have done this by adding table coloumn and then InsertTableCellEditor and then selecting Check Box.

Now I am getting error while running the program:

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Property 'checked' of AbstractToggle with id 'CheckBox' in view 'ProgressionView' must be bound to the context

What I have to do here to resolve the issue?

I have to provide 'select all check boxes' and 'deselect all check boxes' option. How I can do so?

User will select couple of check boxes and then click on push button "Run". When the user will click on "Run" button, we have to call another RFC. How we can do so? We have to pass the values of table fields of selected rows.

Regards,

Gary

Accepted Solutions (1)

Accepted Solutions (1)

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 Experts,

1) I have created the check box button by the steps mentioned above. However the check box field is readonly. I can not change its status from check to unchecked and unchecked to checked. How I can make the check box editable ie. I can change its stauts?

2) Also how I can create the "Select All" and "Deselect All" button. I don't have any idea. I guess I have to do some thing with coloumn_header.

Please help.

Regards,

Gary

Former Member
0 Kudos

Hi,

Can you check the readonly property of the table. It should be set to false. And enable property should be set to true.

in onAction of "SelectAll" button write the below code:

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

{

wdContext.nodeTableNode().getTableNodeElementAt(i).setIsSelected(true);

}

in onAction of "DeselectAll" button write the below code:

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

{

wdContext.nodeTableNode().getTableNodeElementAt(i).setIsSelected(false);

}

Note: Before doing all these things the TableNode should be initialized with atleast one element.

IprivateTestView.ITableNodeElement element=wdConext.createTableNodeElement();

wdContext.nodeTableNode().addElement(element);

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

Thanks.

I checked the readonly property of the table as well as the coloumn checkbox. It is set to false. And enable property is set to true. However still I am unable to tick or untick the checkbox.

For 'select all' and 'deselect all' where I have to create the push button.

Regards,

Gary

Former Member
0 Kudos

Hi Gary,

1. R.click on table and select "Insert Tool bar".

2. Now r.click on tool bar and select "Insert Toolbar Item"

3. There you can select one "Tool bar button"

And regarding check box problem..

I think, the value node needs to be instantiated to get the checkbox enabled. Define a supply function for the value node. For more details just go thru this blog:

/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro

Regards,

Jaya.

Former Member
0 Kudos

you can create Select and deselect all buttons outside table or you can create a tool bar for that table and add those buttons with in the tool bar. Also create two actions and bind to the buttons respectively and include the code in the above post in those actions as required.

Regarding Check box,which value attribute of the node you have mapped. Did u map directly to the output model node of R3 or to Value node you created.

If it is value node,you should create few elements for that node to make check box enable

Former Member
0 Kudos

Hi Jaya,

All the issues got resolved. However, I am still unable to enable the check box. I am unable to change it from Uncheked to Checked.

I am gone through following link:

/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro

It is not helping.

Following line of code is not getting compiled:

ISpecialParametersElement elem = node.createSpecialParametersElement();

One question - I have created the Value Node for check box at 2 places both Controller and View. After that I have done mapping. Is this correct?

Please help.

Regards,

Gary

Former Member
0 Kudos

Have you tried to set the "selection" cardinality of the context node providing the table rows to "0:n" (multiple selection)? In that case the table provides multi-selection automatically (not by check boxes, but by selection buttons in the first columns) and you will get a menu in the left-upper corner of the table with "Select All", "Deselect All" items.

Armin

Former Member
0 Kudos

Hi Armin,

I set the cardinality to 1:1.

There are large no of records in table. So, I can not believe on the selection automatically provided by selection 0:n.

Regards,

Gary

Former Member
0 Kudos

What does that mean?

Armin

Former Member
0 Kudos

Hi Gary,

Since the API for singleton node and nonsingleton node changes, please provide the singleton property value of each node. I will give the complete code.

Regards,

JayaRam.

Former Member
0 Kudos

Hi Armin,

The table has approx 100 records. So the records will be displayed in say approx 5 pages. Now suppose the user has to select say some record of 1st page and some records of 2nd page then how 'selection button in first coloumn' mentioned below can help.

Have you tried to set the "selection" cardinality of the context node providing the table rows to "0:n" (multiple selection)? In that case the table provides multi-selection automatically (not by check boxes, but by selection buttons in the first columns) and you will get a menu in the left-upper corner of the table with "Select All", "Deselect All" items.

As if the user will change the page then selection of first page may not remain in tact.

Regards,

Gaurav

Former Member
0 Kudos

Hi,

Regarding checkboxes:

How come you are not able to edit the checkboxes? Please confirm : You are able to see the check box for each row and not able to edit right?

If that is the case it that value node which you binded to table is directly under ROOT node? Or it is under someother value node?

Did you initialize(creating and adding atlest one element ) that node?

Regarding multi selection without check boxes:

if you use node with selection (0..n) and table selectionMode propery to multi, User can select multiple records usig ctrl & shift keys on the screen.

The selection remains same even if user navigates to next set of records.

Regards,

Charan

Former Member
0 Kudos

Hi Gary,

To enable the checkboxed, try changing the cardinality of value node to 1..1. It will automatically get instantiated.

Regards,

Jaya.

Answers (2)

Answers (2)

former_member205363
Contributor
0 Kudos

Hi Gary,

Error is coming because you are not giving the context attribute to the checked property of checkbox.

Do like this,

Create valueAttribute of type boolean to the Table Context Node and attach the attribute to the check box.

Now you can retrieve the each row check box by iterating the Table Node.

Regards,

Lakshmi Prasad.

Former Member
0 Kudos

Hi Gary,

You have to bind a value attribute to the checked property of check box UI element. The value attribute should be of type boolean.

And you can do this by creating a value node in your model node.

Suppose the model node which contains all the records is nodeResult() then do the steps like this.

1. create a value node under nodeResult()

2. change the node singleton property to false.

3. create a value attribute <check_box_value> under value node.

4. now bind the same in the table. (Your table contains columns which represents model attributes of nodeResult() node and value attribute of value node which is under nodeResult()).

when the use clicks on "selects all check boxes" then loop through the nodeResult() and get each element of valunode() and set the value of valueattribute to true. similarly for "deselect all check boxes" change the value of value attribute to false.

Let me know if you need any further help.

Regards,

Jaya.