Announcement

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

    Custom Widget

    Hello,

    I've a "little" problem with custom widgets.I would like to create a custom widget TEST which is basically just a TreeGrid. I used the example code from the smartGWT Showcase Example.

    Everything works fine. Now I embed the code in a class which inherits from
    Composite. If I use the widget like this:

    Code:
    RootPanel panel = RootPanel.get("searchBody");
    		
    TEST test = new TEST();
    
    panel.add(test);
    ...everything works fine.

    But if i use the widget in this way:


    Code:
    		RootPanel panel = RootPanel.get("searchBody");
    		
    		TEST test = new TEST();
    
    		HLayout left = new HLayout();
    		left.setWidth100();
    		left.setHeight100();
    		HTMLPane htmlPane = new HTMLPane();
    		htmlPane.setShowEdges(true);
    		htmlPane.setContentsURL("http://google.com");
    		htmlPane.setContentsType(ContentsType.PAGE);
    
    		left.addMember(htmlPane);
    		left.addMember(test);
    		
    		panel.add(left);
    ...i get a bug (?):

    I can't open and close (toggle) the items in the tree grid. The tree grid is kinda dead. It looks fine but you can't click anything -> you can't open close the nodes.

    There is no JS error, no Error in the Log console etc. Any idea what this might could be/cause?

    IMPORTANT:
    - in IE7 it works fine
    - Chrome 7.0.517.44 --> works







    Version:

    smartgwt-2.2
    FF 3.6.12

    3. for a client-side problem, the contents of the Developer Console...

    Code:
     
    09:47:00.407:INFO:Log:initialized
    09:47:00.607:WARN:AutoObserver:Use addInterfaceProperties() to add methods to interface [Class AutoObserver]
    09:47:00.881:INFO:Log:isc.Page is loaded
    4. if there is a JavaScript error, the stack trace logged in the Developer Console (from Internet Explorer if possible); and

    No Errors

    5. sample code.

    Code:
     
    public class Init implements EntryPoint {
    
    	public void onModuleLoad() {
    
    
    		RootPanel panel = RootPanel.get("searchBody");
    		
    		TEST test = new TEST();
    
    		HLayout left = new HLayout();
    		left.setWidth100();
    		left.setHeight100();
    		HTMLPane htmlPane = new HTMLPane();
    		htmlPane.setShowEdges(true);
    		htmlPane.setContentsURL("http://forums.smartclient.com");
    		htmlPane.setContentsType(ContentsType.PAGE);
    		left.addMember(htmlPane);
    		left.addMember(test);
    		
    		panel.add(left);
    
    	}
    
    	public static class EmployeeTreeNode extends TreeNode {
    
    		public EmployeeTreeNode(String employeeId, String reportsTo, String name) {
    			setEmployeeId(employeeId);
    			setReportsTo(reportsTo);
    			setName(name);
    		}
    
    		public void setEmployeeId(String value) {
    			setAttribute("EmployeeId", value);
    		}
    
    		public void setReportsTo(String value) {
    			setAttribute("ReportsTo", value);
    		}
    
    		public void setName(String name) {
    			setAttribute("Name", name);
    		}
    	}
    }
    
    
    
    
    
    public class TEST extends Composite {
    	
    
    
    	public TEST() {
    		
    		super();
    
    		TreeGrid treeGrid = new TreeGrid();
    		treeGrid.setWidth(300);
    		treeGrid.setHeight(400);
    
    		TreeGridField field = new TreeGridField("Name", "Tree from local data");
    		field.setCanSort(false);
    
    		treeGrid.setFields(field);
    
    		final Tree tree = new Tree();
    		tree.setModelType(TreeModelType.PARENT);
    		tree.setNameProperty("Name");
    		tree.setIdField("EmployeeId");
    		tree.setParentIdField("ReportsTo");
    		tree.setShowRoot(true);
    
    		EmployeeTreeNode root = new EmployeeTreeNode("4", "1", "Charles Madigen");
    		EmployeeTreeNode node2 = new EmployeeTreeNode("188", "4", "Rogine Leger");
    		EmployeeTreeNode node3 = new EmployeeTreeNode("189", "4", "Gene Porter");
    		EmployeeTreeNode node4 = new EmployeeTreeNode("265", "189", "Olivier Doucet");
    		EmployeeTreeNode node5 = new EmployeeTreeNode("264", "189", "Cheryl Pearson");
    		tree.setData(new TreeNode[] { root, node2, node3, node4, node5 });
    
    
    		treeGrid.setData(tree);
    		
    		initWidget(treeGrid);
    		
    		
    		
    		
    
    	}
    
    	
    
    	public static class EmployeeTreeNode extends TreeNode {
    
    		public EmployeeTreeNode(String employeeId, String reportsTo, String name) {
    			setEmployeeId(employeeId);
    			setReportsTo(reportsTo);
    			setName(name);
    		}
    
    		public void setEmployeeId(String value) {
    			setAttribute("EmployeeId", value);
    		}
    
    		public void setReportsTo(String value) {
    			setAttribute("ReportsTo", value);
    		}
    
    		public void setName(String name) {
    			setAttribute("Name", name);
    		}
    	}
    }
    Last edited by cage97; 16 Nov 2010, 01:15.
Working...
X