问题描述
我正在尝试绑定一个 FilteringSelect
的 onChange
事件以填充另一个 FilteringSelect
.
I'm trying to bind an onChange
event of one FilteringSelect
to populate another FilteringSelect
.
// View
dojo.addOnLoad(function () {
dojo.connect(dijit.byId('filterselect1'), 'onChange', function () {
dijit.byId('filterselect2').store = new dojo.data.ItemFileReadStore(
{ url: "/test/autocomplete/id/" + dijit.byId("filterselect1").value }
);
});
});
JSON 是根据我可以使用 autoCompleteDojo
帮助程序从 Zend 动作控制器正确判断的内容生成的.
The JSON is generated from what I can tell correctly from a Zend Action Controller using a autoCompleteDojo
helper.
// Action Controller
public function autocompleteAction()
{
$id = $this->getRequest()->getParam('id');
$select = $this->_table->select()
->from($this->_table, array('id','description'))
->where('id=?',$id);
$data = new Zend_Dojo_Data('id', $this->_table->fetchAll($select)->toArray(), 'description');
$this->_helper->autoCompleteDojo($data);
}
我从远程数据存储正确接收了 JSON,但它没有填充第二个 FilteringSelect
.我还需要做些什么来将 JSON 推送到 FilteringSelect
上?
I receive the JSON from the remote datastore correctly, but it does not populate the second FilteringSelect
. Is there something else I need to do to push the JSON onto the FilteringSelect
?
推荐答案
我不敢相信这是导致问题的原因,但整个问题归结为以下事实:dojo ItemFileReadStore REQUIRES JSON 的标签属性为名称".最后,这就是将它们连接在一起所需的全部内容.
I couldn't believe this was causing the problem, but the whole issue boiled down to the fact that it appears that a dojo ItemFileReadStore REQUIRES the label property of the JSON to be "name". In the end this is all that it required to wire them together.
dojo.addOnLoad(function () {
dijit.byId('filtering_select_2').store = new dojo.data.ItemFileReadStore({url: '/site/url'});
dojo.connect(dijit.byId('filtering_select_1'), 'onChange', function (val) {
dijit.byId('filtering_select_2').query.property_1 = val || "*";
});
});
更新:Zend 表单中的属性已从 ZF 1.8.4 开始修复
UPDATE: The property within Zend form has been fixed as of ZF 1.8.4
这篇关于从 onChange 事件填充 FilteringSelect 数据存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!