使用异步数据更新Dojo Dijit FilteringSelect的存储 [英] Updating Dojo Dijit FilteringSelect's store with asynchonous data
问题描述
简而言之,我已经定义了一种通用方法,允许您将一个onBlur更新设置为一个表单域。这链接到控制器动作,使用函数参数调用数据库,并返回单例响应(我们已经处理好了)或列表响应。如果我们收回列表,我们需要更改列表中选择的选项。
所有这些都可以正常运行;我们在response.data中得到一个有效的json响应。这里是问题所在。如何只更新现有的商店(检查显示它是一个_comboBoxDataStore)?因为它是自动生成的,所以我不能使用不同种类的商店声明选择。
有没有什么办法强制交换商店?主要的关键是无论我做什么,都必须在Internet Explorer中工作;我使用Firefox只是为了更好地了解我正在使用的对象。
作为一个副问题,有没有人知道为什么_comboBoxDataStore不能更新?其他框架允许商店的无缝更新,例如extJS。在组合框中设计限制是否有任何推理,因此无法更新,这是从原始HTML中降下来的?或者我错过了一个明显的解决方案,它不涉及玩杂耍的深奥对象列表?
根据RiverC的帖子我的更新组合工具的方法如下所示:
,updateData:function(data){
var storeData = data:data,id:'attrFilterStore'};
var newStore = new dojo.data.ItemFileWriteStore({data:data});
this.element.store = newStore;
this.element.startup();
}
其中 this.element 是一个引用到 FilteringSelect 对象。
方法 updateData 是一个来自ajax请求的回调函数,它接收到带有RiverC结构的JSON的JSON。 p>
I'm using Zend + Dojo form in an intranet context. We need to update a list of counties when the selected state is changed on a form. With HTML you would just parse the json response (or just provide a html fragment of options) and update the innerhtml of the select. However, doing so in Dojo has proved to be prohibitively complex.
In short, I have defined a generic method that allows you to set an onBlur update to a form field. This links to a Controller action that calls the database with a function arguments, and gets back either a singleton response (which we handle okay already) or a list response. If we get back a list, we need to alter the options in a select with that list.
All of this works fine so far; we get a valid json reponse with a nice list in response.data. Here's where the problem is. How can I simply update the existing store (examination reveals it is a _comboBoxDataStore)? I cannot declare the select with a different kind of store, since it is auto-generated.
Is there any way to brute force a swap of stores? The main key is that whatever I do it has to work in Internet Explorer; My use of Firefox is only to allow better insight into the objects I'm working with.
As a side question, does anyone know why _comboBoxDataStore cannot be updated? Other frameworks allow for pretty seamless updating of stores, like for instance, extJS. Is there any reasoning behind designing a limitation into the combobox so it cannot be updated, which is a step down from raw HTML? Or am I missing the obvious solution that doesn't involve juggling a list of esoteric objects?
Based on post of RiverC my method for updating the combo works fine like this:
, updateData : function(data) {
var storeData = {data: data, id:'attrFilterStore'};
var newStore = new dojo.data.ItemFileWriteStore({data: data});
this.element.store = newStore;
this.element.startup();
}
Where "this.element" is a reference to the FilteringSelect object.
The method "updateData" is a callback function from an ajax request which receives JSON with the structure RiverC posted.
这篇关于使用异步数据更新Dojo Dijit FilteringSelect的存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!