gpt4 book ai didi

zend-framework - 搜索一个值并在 Dojo FilteringSelect 上显示另一个值

转载 作者:行者123 更新时间:2023-12-04 12:54:52 24 4
gpt4 key购买 nike

我在 Zend 表单上一起使用了 dojo FilteringSelect 元素,但我无法让它按我的意愿工作。我有一个包含三个字段的商店 id , label , name .标签将用于下拉菜单,应为 还有用于搜索,而 name应用于盒内的展示。问题是我找不到使这种行为起作用的方法。

设置labelAttr值为 label可以在下拉列表中显示它,但 searchAttr一旦选择了一个值,属性就会控制搜索和输入框上的显示。我需要搜索 label字段,因为它是许多字段的集合,但在 name 上显示值, 是否可以?

编辑:@RichardAyotte Dijit FilteringSelect 小部件使用 dojo.data.store,它基本上是一个 javascript 对象,其中每个项目也是一个具有许多参数的对象。您可以在商店设置两个特殊参数:标签属性 搜索属性 这将定义一些行为。 FilteringSelect 绑定(bind)到一个输入框,您可以在其中进行搜索。如果单击该框,它将打开选项列表,例如 将。在这里,它显示了您定义为 labelAttr 的任何内容。现在,如果您在框中键入,它将使用 中定义的内容在商店中搜索。搜索属性 field 。一旦您从列表中选择某些内容,它还使用标签的值显示在输入中(您可以在此处查看 http://dojotoolkit.org/reference-guide/1.9/dijit/form/FilteringSelect.html#displaying-rich-text-menu-labels-with-labelattr-and-labeltype)

我想做的是“解耦” 搜索属性 字段分为 2 个不同的字段,一个用于搜索,另一个用于在输入中显示。 AFAICT 虽然这是不可能的,我将不得不扩展 FilteringSelect 对象

最佳答案

你可以用 AOP 做这种事情。见 dojo/aspect .

警告 :向私有(private)函数 _announceOption 添加建议。

var countryField = new FilteringSelect({
label: 'Country'
, name: 'country_id'
, searchAttr: 'name'
, labelAttr: 'label'
, store: new CountryStore()
});

aspect.around(countryField, '_announceOption', function(origFunction) {
return function(node) {
this.searchAttr = 'label'
var r = origFunction.call(this, node);
this.searchAttr = 'name'
return r;
}
})

关于zend-framework - 搜索一个值并在 Dojo FilteringSelect 上显示另一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17791247/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com