cancel
Showing results for 
Search instead for 
Did you mean: 

Check box within a table cell

Former Member
0 Kudos

Hi All,

I have a table with a column for name and about 30 columns for days, and each table cell has a check box. I need to get the values of only checked boxes and save them. Similarly, while editing, I have to fetch values from database and display them accordingly. Also suggest how to fix column size, as setting values for width does not have any effect and it keeps expanding as the text increases. I need to wrap the text and display within a fixed width of column. Do have any solution?

Regards,

Srinivasan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

srinivasan,

As Mausam suggested, you need 30 attributes of type boolean and 30 corresponding columns. I would create this attributes and columns dynamically, while creating all this manually is sooo tedious...

Regarding second question, you may set percentage width to all the rest columns, sum of this percentage width should be equals to 100% (i.e. if you have one column, set it width to 100%, if 2 -- say, 30% and 70% etc). For all "days" columns set absolute width, for check-boxes 28px along with textAlign=center looks quite pretty.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi,

As suggested by Mausam, I have created a column for name and 3 columns for days with checkbox(testing purpose) and did necessary binding. I am able to get the value of the selected box looping through row. But whenever I click the box in the first row, boxes in other rows too get selected. How can I handle this and fetch value of only selected cell element? Also tell how can I make the checkbox display appropriately on the basis of value from database?

As suggested by you, I have set checkbox to 28 px, still I see space around it. I want them to fit exactly in the cell. Any other idea?

Srinivasan

Former Member
0 Kudos

Hi

Create a attribute of type boolean for the checkbox in side the node u have binded the table data source property.

Hope this helps.

Regards,

Rathna.

Former Member
0 Kudos

Srinivasan,

Node where check-box attributes are located should be either the same node as table data source, or <b>non-singleton</b> child of thereof.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi,

Create attributes of type boolean (in this case 30) inside the node (TableNode) that u have bind to the table. Now to get values of the check box write this code:

Iprivate<view>.ITableNodeElement tabEle;

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

{

tabEle = wdContext.nodeTableNode().getTableNodeElementAt(i);

// tabEle.getCol1() will return the boolean value if its ticked or not, and u can store that value accordingly.

tabEle.getCol1();

tabEle.getCol2();

...

...

...

tabEle.getCol30();

}

Also on selecting a checkbox, it wont select all other checkbox in rest of the rows.

Creating attributes and check box will be a better solution, else it will be tedious to make all 30 attributes.

To create attributes dynamically:

IWDAttributeInfo attrInfo;

//loop 30 times i++.

attrInfo = wdContext.nodeTableNode().getNodeInfo().addAttribute("colAtt"+i,"boolean");

Similarly u can create table columns:

IWDTable tab = (IWDTable)view.getElement("Table1");

//loop 30 times i++.

IWDCheckBox ch = (IWDCheckBox)view.createElement(IWDCheckBox.class,"check"+i);

IWDTableColumn col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"Col"+i);

col.setTableCellEditor(ch);

ch.bindChecked("TableNode.colAtt"+i);

This code might help u.

Regards,

Piyush.

Former Member
0 Kudos

Hi Srinivasan,

For the 1st question,

I would make a node with an Attribute of String Type for NAME, and for checkbox as per my understanding you have to create 30 attributes of Boolean type and assign each attribute to each checkbox in table.

Then you can loop through all the rows of the table and get the value of each Attribute.

This looks a weird solution...I'm not sure if we can use Arrays here.

Hope this helps,

Regards,

Mausam

Former Member
0 Kudos

Hi

For getting the values of checked box:

Try the below code in ur implementation.

//check the condition if the box is checked.

if(wdContext.current<node>element.get<attribute name>)

{

String name= wdContext.current<node>element.get<value_attribute>;

.

.

.

}

For wrapping the text:

Set the wrap property of the tablecelleditor as true and set the width.

Regards,

Rathna.