2011-12-14 52 views
0

從此示例http://www.smartclient.com/smartgwt/showcase/#tree_databinding_local開始,我開始動態實現自己的樹結構(TreeGrid)。當我嘗試渲染它時,我得到這個錯誤(標題)。SmartGWT - 創建組件後無法更改配置屬性「x」

public class ProjectTreeGridScreen extends Screen { 

    Tree tree; 

    @Override 
    protected void onLoad() { 
    super.onLoad(); 

    TreeGrid treeGrid = new TreeGrid(); 

    setPageTitle(Util.C.projectListTitle()); 

    treeGrid.setWidth(600); 
    treeGrid.setHeight(400); 

    TreeGridField projectTree = new TreeGridField("ProjectName", "Project Tree"); 
    TreeGridField projectPath = new TreeGridField("ProjectPath", "Complete path"); 
    TreeGridField projectDescription = new TreeGridField("ProjectDescription", "Description"); 
    TreeGridField projectInfo = new TreeGridField("ProjectInfo", "Information"); 

    treeGrid.setFields(projectTree, projectPath, projectDescription, projectInfo); 

    treeGrid.setData(tree); 

    add(treeGrid); 

    } 

    @Override 
    protected void onInitUI() { 
    super.onInitUI(); 
    tree = new Tree(); 

    tree.setModelType(TreeModelType.PARENT); 
    tree.setNameProperty("ProjectName"); 
    tree.setIdField("ProjectItem"); 
    tree.setParentIdField("ProjectParent"); 

    tree.setShowRoot(true); 

    populateProjects(); 

    } 

    protected void populateProjects() { 

    Util.PROJECT_SVC.visibleProjects(
     new ScreenLoadCallback<List<Project>>(this) { 
     @Override 
     public void preDisplay(final List<Project> result) { 
     tree.setData(ProjectTreeGridBuilder.fromRepositories(result)); 
     } 
    }); 

    } 

} 
+1

顯示實際的錯誤完整的錯誤信息,這很重要,這就是爲什麼框架顯示它:) – 2011-12-15 01:17:12

回答

1

什麼叫「X」是什麼意思?通常情況下,如果組件已經在窗口上繪製(隱式或顯式調用繪製),則無法更改其屬性值。所以唯一可能的解決方案是每次改變時都用新的值重新創建對象。

+0

這就是我做的thx。我沒有發佈我的解決方案。每次我完成從服務器獲取數據時,我都會創建我的窗口(添加函數)。我想在獲取數據時將我的數據填充到網格中,但我想你不能這麼做...... – fneron 2011-12-18 22:42:10

相關問題