将属性传递给dojo小部件并刷新

passing properties to dojo widget and refresh

本文关键字:小部 刷新 dojo 属性      更新时间:2023-09-26

我有一个作业,我被困在一个部分,因为我正在学习dojo小部件。

首先,我创建了包含布局(左、中、下窗格)的主小部件。在左窗格中,我附加了树小部件(树中列出了员工姓名)。在中心窗格中,我根据需求附加了一个自定义小部件(员工详细信息)。在底部窗格中也是如此,数据网格,根据需求自定义小部件(网格中的其他员工详细信息)。

我计划编写代码,以便我可以单击左窗格的树小部件的子节点,并将员工的ID传递给其他两个小部件(中间窗格和底部窗格的小部件)的属性,并在每次单击时看到相应的员工详细信息。

这就是我被卡住的地方。我不能在小部件上传递值,因为它们是独立的实体。

树小部件(位于左窗格):

var tree = new dijit.Tree({model: tree_model, onClick: function(e){
console.log(e.id[0]); /*clicking on the tree nodes, i'm able to see the user id of the current selection*/
}); 

底部网格(底部窗格的自定义小部件):

var bottomGridWid = new custom.bottomGrid({default_user_id: userid});
//passing different userid to the widget will automatically query the grid and display the result 

如果在创建时没有提供,则为所有小部件提供唯一的Id。在您的示例中,最好在小部件创建期间为其提供唯一ID。使用ID获取小部件的保持(引用)。需要使用API dijit.registry.byId()来获取对小部件的引用
请看下面的链接
http://dojotoolkit.org/reference-guide/1.9/dijit/registry.html
获得小部件后,您可以使用小部件特定的API对其进行操作。