Announcement

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

    IPickTreeItem in ListGrid

    Hi, This is a client side problem. I'm using smartGWT 2.2 for the sample code below.

    By running the code below, you will realized that the IPickTreeItem is not working properly when u use it for editing.

    There are a few post in the forum but none of them provides a work around. I have identified the problem.
    It's due to the display name being too long.

    The IPickTreeItem will fail to expand it's width in the list grid and "fallback" to it's original state. It can be verifiied by expanding the width of the list grid. You will see that the picker will work normally.

    Any insight/suggestion to this problem is welcomed. This problem has been bothering me and many out there for too long.

    I have tried setting the width, wrap, etc fields. None of them work.

    Code:
    package com.test.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.grid.ListGridRecord;
    import com.smartgwt.client.widgets.tree.Tree;
    import com.smartgwt.client.widgets.tree.TreeNode;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    public class SmartgwtTest implements EntryPoint
    {
    
    	/**
    	 * This is the entry point method.
    	 */
    
    	
    	public void onModuleLoad()
    	{
    
    		ListGridField componentIdField = new ListGridField("Id", 50);
    		ListGridField componentNameField = new ListGridField("Name", 200);
    		ListGridField nodeField = new ListGridField("NodeId", 300);
    		final IPickTreeItem nodePicker = new IPickTreeItem("Editor");
    		
    		Tree tree = new Tree();
    		DepartmentTreeNode root = new DepartmentTreeNode("0", "root", new DepartmentTreeNode("1", "Node1 some super long text that cannot be place in the drop down list") , new DepartmentTreeNode("3" ,"Node2" , new DepartmentTreeNode("4", "Node2-1")));
    		
    		tree.setRoot(root);
    		nodePicker.setTitle("Node Picker");
    		nodePicker.setValueField("DepartmentId");
    		nodePicker.setDisplayField("name");
    		nodePicker.setValueTree(tree);
    		nodeField.setEditorType(nodePicker);
    		
    		nodeField.setCanEdit(true);
    		
    		
    		ListGrid grid = new ListGrid();
    		grid.setModalEditing(false);
    		grid.setFields(componentIdField,componentNameField,nodeField);
    		grid.setCanEdit(true);
    		ListGridRecord gridlist[] = new ListGridRecord[5];
    
    		for (int i = 0; i < 5; i++)
    		{
    			gridlist[i] = new ListGridRecord();
    			gridlist[i].setAttribute("Id", i);
    			gridlist[i].setAttribute("Name", "component" + i);
    			gridlist[i].setAttribute("NodeId" , "Node" + i);
    			
    		}
    		grid.setWidth100();
    		grid.setHeight(500);
    		
    		grid.setData(gridlist);
    		
    		RootPanel.get().add(grid);
    		
    		DynamicForm df = new DynamicForm();
    		df.setItems(nodePicker);
    		RootPanel.get().add(df);
    	}
    	
    	public static class DepartmentTreeNode extends TreeNode {  
    		  
            public DepartmentTreeNode(String id, String name) {  
            	setAttribute("DepartmentId", id);
            	setAttribute("name", name);
                setName(name);  
            }  
      
            public DepartmentTreeNode(String id, String name, DepartmentTreeNode... children) {  
            	setAttribute("DepartmentId", id);
            	setAttribute("name", name);
            	setName(name);  
                setChildren(children);  
            }  
        }  
    }
Working...
X