cancel
Showing results for 
Search instead for 
Did you mean: 

Lead Selection in tree by nesting table column compatibility nw04plus

Former Member
0 Kudos

Hello guys,

Please let me know a solution for the following issue.

I have a tree by nesting table column in a similar fashion.

==RootElement1

-


.childElement1

-


.childElement2

-


.childElement3

==RootElement2

-


.childElement1

-


.childElement2

-


.childElement3

The table column has a check box as the table cell editor. In this case, when i check the root element, all the child elements pertaining to the selected rootelement will be selected and vice versa. now when i uncheck the child element, the root element will also get unchecked. I am using the code as below to do the same.


<DO modify view>

if(firstTime)
    {
    	IWDTreeByNestingTableColumn tableColumn = (IWDTreeByNestingTableColumn)view.getElement("MasterColumn");
    	tableColumn.mappingOfOnLoadChildren().addSourceMapping("path","element");
    	
    	IWDCheckBox checkBox = (IWDCheckBox)view.getElement("CheckBox");
    	checkBox.mappingOfOnToggle().addSourceMapping("nodeElement","nodeElement");
    	
    }


<Action ontoggle of the checkbox>
 public void onActionToggleBox(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.arteriatech.demo.wdp.IPrivateDemoCompView.IVnTreeNodeElement nodeElement )
  {
    //@@begin onActionToggleBox(ServerEvent)
    
    if(nodeElement.getVaCheck() && !nodeElement.getVaIsLeaf())
    {
    	for(int i=0;i<nodeElement.nodeRecTree().size();i++)
    	{
    		nodeElement.getRecTreeElementAt(i).setVaCheck(true);
    	}
    }
    else if(!nodeElement.getVaCheck()) 
    {
		if(!nodeElement.getVaIsLeaf())
		{
			for(int i=0;i<nodeElement.nodeRecTree().size();i++)
			{
				nodeElement.getRecTreeElementAt(i).setVaCheck(false);
			}
						
		}
		else
		{
			int curr_sel = nodeElement.node().getParentElement().node().getLeadSelection();
			wdComponentAPI.getMessageManager().reportSuccess("1-->"+nodeElement.node().getLeadSelection());
			wdComponentAPI.getMessageManager().reportSuccess("2-->"+curr_sel);
			wdContext.nodeVnTreeNode().getVnTreeNodeElementAt(curr_sel).setVaCheck(false);

		}
		
    }

Please note,

This scenario works fine when i have the table property selection mode = none, compatibility mode = auto. But when i change the compatibility mode to nw04plus, the first root element gets unchecked when i uncheck the child element belonging to other root elements i.e., the lead selection of the root element always remains 0.

Hence let me know a solution for the same.

Regards,

Karthikeyan R

Accepted Solutions (1)

Accepted Solutions (1)

sanyev
Active Participant
0 Kudos

Hi Karthikeyan,

When you check or uncheck a checkbox the leadselection will not move to the row where you checked. It will remain where it was earlier. In your case the leadselection was always at the first row of the Hierarchical Table. So instead of using the leadselection you can directly get the parent element and set the checkbox.

IPrivateVnTreeNodeElement parentTreeElement = (IPrivateVnTreeNodeElement) nodeElement.node().getParentElement();
parentTreeElement.setVaCheck(false);

Hope this helps.

Regards,

Sanyev

Former Member
0 Kudos

Hi Sanyev,

Thanks a lot . your code actually resolved my problem.This can also be done in a more optimized way such as


nodeElement.node().getParentElement().setAttributeValue("vaCheck",Boolean.valueOf(false));

Regards,

Karthikeyan R

Answers (0)