Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Setting TreeGrid values causes to redraw SelectItem

    Hi,

    i am facing one issue where i am trying to load a tree on selection of a item on the click of a drop list item

    below is the configuration in ui.xml file

    <smt:UIHLayout ui:field="selectFolderLayout" height="20" width="100%" layoutHAlign="LEFT">
    <smt:UILabel ui:field="selectFolderLabel" autoFit="true" wrap="false" contents="Select folder:"/>
    <smt:UIDynamicForm ui:field="selectFolderForm" height="100%" width="100%" layoutHAlign="LEFT" >
    <smt:UISelectItem showTitle="false" ui:field="folderViewMenu" showAllOptions="true" width="100%"/>
    </smt:UIDynamicForm>
    </smt:UIHLayout>

    <smt:UIHLayout ui:field="folderListContainer" height="100%" >
    <smt:UITreeGrid ui:field="folderpaneTreeGrid" canEdit="true" canCollapseGroup="true"/>
    </smt:UIHLayout>

    Here SelectItem will have some per-populated values to select (ex: folder1, folder2, folder3 ...), on select of an option it has to redraw the tree with new folder structure, below is the sample code

    registerHandler(getView().getFolderViewMenu().addChangeHandler(new ChangeHandler() {
    public void onChange(ChangeEvent event) {
    String mode = event.getValue().toString();
    if(mode != null){
    getView().setTreeDataOnSelect(mode); //Mode will have the folder name which needs to be drawn on folderpaneTreeGrid
    }
    }
    }));

    public void setTreeDataOnSelect(String name){
    ArrayList<FolderTreeData> folderTreeNodelist = new ArrayList<FolderTreeData>();
    folderTreeNodelist = folderNodelist.get(name);//this is a map which will have all the folder structure with parent and child

    createTree(); // problem code

    FolderTreeNode[] nodeArray = new FolderTreeNode[folderTreeNodelist.size()];
    FolderTreeNode node;
    int count=0;

    for(FolderTreeData data : folderTreeNodelist){
    node = new FolderTreeNode(data.getFolderName(), data.getID(), data.getPath(), data.getParent());
    nodeArray[count++] = node;
    }

    tree.setData(nodeArray);
    folderpaneTreeGrid.setData(tree);
    folderpaneTreeGrid.setShowHeader(false);
    folderListContainer.add(folderpaneTreeGrid);
    folderpaneTreeGrid.canEditCell();
    folderpaneTreeGrid.setCanEdit(true);
    folderpaneTreeGrid.setBorder("0px solid #999999;");
    folderpaneTreeGrid.redraw();
    }

    public void createTree(){
    tree = new Tree();
    tree.setModelType(TreeModelType.PARENT);
    tree.setNameProperty("Name");
    tree.setIdField("ID");
    tree.setParentIdField("Parent");
    }


    This is the code where i am setting the selectitem values

    folderViewMenu.setValueMap(folderMap);
    folderViewMenu.setDefaultToFirstOption(true);


    when i change the value and select a folder name (ex: folder2) to draw into treegrid it redraws the tree structure with folder2 content but the selectitem defaults to first element which is folder1 always.

    but if i comment out the createTree() method , selectitem displaying the selected values (which is folder2) but it doesn't draws the tree with folder2 content

    can you please help on this


    Thanks


Working...
X