cancel
Showing results for 
Search instead for 
Did you mean: 

Checkbox in recursive tree

Former Member
0 Kudos

Hi,

i have created a recursive tree

Now i want to do the following things

1. Provide a checkbox to every node

2. if a node is checked then all its subnodes should be checked

(This is like context mapping in web dynpro i.e. if the root node is checked then all the nodes under it also gets checked.)

Can anyone please help me in solving this.

Thanks n Regards

Akshay

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Akshay,

Everything mentioned here step by step:

0. You cannot use check-boxes inside tree, so you have to emulate them with images (or use Table with Tree-like master column -- not discussed in this message)

1. Create boolean attribute <b>isChecked</b> in node

2. Create calculated read-only string attribute cbIcon, write following in generated getter function:

return element.getIsChecked() ? 
  "~sapicons/b_okay.gif" : "~sapicons/b_canc.gif";

or whatever images you are using.

3. Create & bind action onAction for TreeNode / TreeItem.

-- apply parameters mapping in wdDoModifyView:

if ( firstTime )
{
  final IWDTreeNodeType treeNode = (IWDTreeNodeType)
    view.getElement("<your-tree-node-element-id>");
  treeNode.mappingOfOnAction()
    .addSourceMapping("path", "selectedElement");
}

<b>Your action must define parameter with type of your node element and name <i>selectedElement</i></b>

-- write the following code for handler:

selectedElement.setIsSelected( !selectedElement.getIsSelected() );

4. Bind cbIcon attribute as TreeNode / TreeItem image source, bind rest of attributes.

--Done.

VS

Former Member
0 Kudos

Hi Akshay ,

Currently there is no way to insert a checkbox(UIElement) in a TreeNode/TreeItem.

What i am suggesting is you can assign an icon to the nodeItem (Checked Icon and UncheckedIcon)

On CLick evenet of treenode you can change the icons (Toggle) and depending upon that you can bind the nodes under that with repective Icons.

Regards, VIP

Former Member
0 Kudos

I am sorry i am totally confused with other things

You can create a ValueAttribute(type String) for storing the imageName and you can change the image on click.

Regards, VIP

Former Member
0 Kudos

Hi VIP,

i thought abt ur reply. but im sorry i dont think i hv properly understood it.

Could u please explain me it in detail.

Thanks n Regards

Akshay

Former Member
0 Kudos

Hi,

If you want to check/uncheck a checkbox you should bind the checked proprty to a context attribute of type "boolean".

So create value attribute of type boolean and bind the checkbox to the same.

Regards, VIP

Former Member
0 Kudos

Hi VIP,

wht u said was absolutely correct. but where do i place the checkbox in a tree.

Thanks n Regards

Former Member
0 Kudos

Hi VIP,

wht u said was absolutely correct. but where do i place the checkbox in a tree.

Thanks n Regards

Akshay

Former Member
0 Kudos

Hi,

Please modify one of the atribute to boolean and bind the checked property of the checkbox to this value attribute.

Similarly you can create another value attribute and store the image filename in that and bind that to the image of the UILEment.

Regards, VIP

Former Member
0 Kudos

Hi VIP,

iidnt understand much of what u said. but still i tried something about making a boolean attribute. i dont think its right and it didnt work either.

Can u please just elaborate of wht u said earlier.

Thanks and Regards

Akshay

Former Member
0 Kudos

Hi Akshay ,

I am not sure weather this is the correct answer or not but just you can give a try !!

Create a action "OnSelect " for the node.

On click just set the attribute value to true or false.(toggle)

Ex: wdContext.currentNodeElelemt().setAttribute(true);

Regards, VIP

Former Member
0 Kudos

Hi VIP,

i tried with the action "onSelect" for the node.

But, setAttributValue method doesnt take boolean value, it takes two args of type String and Object.

if u can suggest anything on this, it will helpful.

I hv got one more thing in mind. in the tree properties there is one property called defaultNodeIconSource and defaultItemIconSource.

i dont know much abt this. but if we can put a image at tht node and change tht image at runtime e.g. making it a checked(tick) one . now we can check the no of images checked and get those multiple nodes selected.

is this possible?

i dont know how to go abt it.

Can u please help in this.

Thanks n Regards

Akshay