- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Dojo 树,我正在尝试在末尾添加一个节点。我尝试通过以下代码更新商店。虽然存储已按树更新,但并未显示新节点。
this.virtualtree.model.store.put({type:"form",parent:"wpRoot",id:"ABC",name:"ABC"});
后来我尝试在模型上使用 PasteItem 函数。下面是代码。但它仍然不起作用。
this.virtualtree.model.pasteItem({"type":"form","parent":"wpRoot","id":"ABC","name":"ABC"},window._self.virtualtree.model.root,window._self.virtualtree.model.root,true,9,true);
请告诉我如何修改树。
最佳答案
您必须将 dojo/store/Observable
与 store.add()
结合使用查看 dojo 在线文档:https://dojotoolkit.org/reference-guide/1.10/dijit/Tree.html#id7
请参阅下面的工作示例:
require([
"dojo/_base/window", "dojo/store/Memory", "dojo/store/Observable",
"dijit/tree/ObjectStoreModel", "dijit/Tree",
"dojo/domReady!"
], function(win, Memory, Observable, ObjectStoreModel, Tree){
// Create test store, adding the getChildren() method required by ObjectStoreModel
var myStore = new Memory({
data: [
{ id: 'world', name:'The earth', type:'planet', population: '6 billion'},
{ id: 'AF', name:'Africa', type:'continent', population:'900 million', area: '30,221,532 sq km',
timezone: '-1 UTC to +4 UTC', parent: 'world'},
{ id: 'EG', name:'Egypt', type:'country', parent: 'AF' },
{ id: 'KE', name:'Kenya', type:'country', parent: 'AF' },
{ id: 'Nairobi', name:'Nairobi', type:'city', parent: 'KE' },
{ id: 'Mombasa', name:'Mombasa', type:'city', parent: 'KE' },
{ id: 'SD', name:'Sudan', type:'country', parent: 'AF' },
{ id: 'Khartoum', name:'Khartoum', type:'city', parent: 'SD' },
{ id: 'AS', name:'Asia', type:'continent', parent: 'world' },
{ id: 'CN', name:'China', type:'country', parent: 'AS' },
{ id: 'IN', name:'India', type:'country', parent: 'AS' },
{ id: 'RU', name:'Russia', type:'country', parent: 'AS' },
{ id: 'MN', name:'Mongolia', type:'country', parent: 'AS' },
{ id: 'OC', name:'Oceania', type:'continent', population:'21 million', parent: 'world'},
{ id: 'EU', name:'Europe', type:'continent', parent: 'world' },
{ id: 'DE', name:'Germany', type:'country', parent: 'EU' },
{ id: 'FR', name:'France', type:'country', parent: 'EU' },
{ id: 'ES', name:'Spain', type:'country', parent: 'EU' },
{ id: 'IT', name:'Italy', type:'country', parent: 'EU' },
{ id: 'NA', name:'North America', type:'continent', parent: 'world' },
{ id: 'SA', name:'South America', type:'continent', parent: 'world' }
],
getChildren: function(object){
// Add a getChildren() method to store for the data model where
// children objects point to their parent (aka relational model)
return this.query({parent: object.id});
}
});
myStore = new Observable(myStore);
// Create the model
var myModel = new ObjectStoreModel({
store: myStore,
query: {id: 'world'}
});
// Create the Tree.
var tree = new Tree({
model: myModel
});
tree.placeAt("test");
tree.startup();
myStore.add({id: 'foo', name:'Added after tree creation', type:'continent', parent: 'world'});
});
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css">
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/tundra/tundra.css">
<div class="tundra">
<div id="test"></div>
</div>
关于javascript - 将节点添加到 Dojo 树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37727183/
如何安装 DOJO 工具包并在我的网站上使用它?有教程吗? 最佳答案 是的: http://docs.dojocampus.org/quickstart/gettingstarted “Dojo 现在
我对 Dojo 的文档感到很困惑。如何在不实际使用 dojo.declare() 的情况下使用 dojo.require()?我不想使用 dojo.declare() 的原因是它将声明的类公开为全局变
我是 Dojo Toolkit 的新手,今天我遇到了这个话题 dojo.mixin()和 dojo.extend() . 我想两者都习惯于从另一个对象获取一个对象的属性。 谁能解释一下 dojo.mi
我的问题是:我们可以使用 dojo.xhrPost 发布一些 Json 数据吗?更多详情: 我一直在尝试使用 Dojo 代码将 JSON 数据发布到 RESTful 服务。似乎是的行为dojo.xhr
我有一个从XMLStore读取的DataGrid。 DataGrid中大约有2200行。每次我滚动表格时,都要花费几秒钟来显示数据。似乎一次只检索了几行(20-25)。有没有办法一次检索所有行? 最佳
在将请求发送到服务器以获取 AMD 模块之前,是否可以修改 dojo AMD 加载程序使用的请求 url?我想附加一个带有版本号的请求参数。 我们试图解决的问题是我们希望浏览器缓存我们的 javasc
当我使用自定义构建的 dojo 时,dojo.currency.format 没有使用正确的货币符号。 这是我使用的语句: dojo.currency.format(1234.567, {curren
我创建了一个非常简单的模板化小部件。像这样的东西: function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,
如何在 dojo 数据网格中显示复选框? 最佳答案 我建议将 cellType 设置为 dojox.grid.cells.Bool,而不是格式化程序。格式化程序为您提供了很大的自由,但也有责任在之后从
收到新信息后,我无法尝试更改数据网格的结构。每次进行查询时,我都需要能够更改列数。 我用来创建网格的 javascript 代码 function setgrid(){ var gridLay
试图找出为什么我似乎无法在我的 dojo 构建中实习字符串。我的图层文件已正确创建,但与每个单独的 dijit 关联的代码未正确嵌入。 这是构建输出的一部分,说明了失败的地方: release: I
我刚刚开始使用道场,我知道 dojo.query与 $ 相同在 jQuery 中。 但我还没有弄清楚它返回什么。它是像 jQuery 一样的专门对象吗? 我正在尝试做的(没有运气)是: dojo.qu
有什么方法可以将按钮 添加到TitlePane 标题(标题栏右侧),以便我可以执行一些操作(下载、删除...) 提前致谢。 最佳答案 dijit TitlePane 标题包含以下内容 -Rule
在使用 dojo 的 gfx 渲染文本时,有没有办法告诉文本将占用多少空间,以防我需要包装它以使其适合给定的宽度? 如果您必须使它们适合宽度受限的区域,您将如何管理打印任意长度的文本? 更新 :对不起
我对 Dojo 工具包有点陌生。有些问题我想得到启发(我用谷歌搜索,但没有得到任何合适且令人满意的答案) 我已经在运行的应用程序(由另一个软件开发人员开发)中有一个 dojo.js(也许是下载的未压缩
我正在使用 dojo 柱形图。我想添加一条绘制在绘图上的自定义线(某种阈值线)。所以,假设 y 轴的范围从 0 到 5。我想要一条水平线,比方说,4.2 横跨绘图。它是一个柱形图。我希望找到一些可以帮
我在设置 dojo 时遇到问题. dojo 中定义的任何内容配置似乎使用 localhost:8080/Scripts/foo.js 正确加载小路。但是,如果我尝试在没有这个的情况下加载模块,请说:
我正在为一个项目使用 Dojo 1.9,但我不明白 dojo.provide 的正确替代方案与传统风格相比,AMD 风格。我正在阅读 this文档页面。 很明显,这就是旧语法映射到新语法的方式: 旧
我们正在使用 Dojo 1.9 运行我们的应用程序的构建,而构建本身需要过多的时间才能完成。某处沿着 10-15 分钟的路线。 我们的应用程序无论如何都不是很大。也许 150K LOC。没有什么花哨。
在我的 Dojo 构建中,我引入了一些第三方库。 当我完成构建过程时,由于 ReferenceErrors,我收到了错误。 这很好。这是有道理的。 但是,我想告诉 Dojo 构建过程所引用的内容。本质
我是一名优秀的程序员,十分优秀!