如何在 Flex datagrid dataProvider 4 中搜索字符串?
我尝试使用filterFunction没有得到任何结果,看看这个例子:
[Bindable]
public var SearchLoadlistOneDP:ArrayCollection;
public function SearchList():void {
SearchLoadlistOneDP.filterFunction = filter;
SearchLoadlistOneDP.refresh()
}
public function filter(item:Object):Boolean
{
var beginsWithString:String = SearchLoadlistOneInput.text;
return String(item["email"]).indexOf(beginsWithString) == 0;
}
我使用了这样的数据网格:
<mx:DataGrid x="10" dataProvider="{SearchLoadlistOneDP}" y="49" width="891" height="408" id="listamail" creationComplete="LoadlistOne(0)">
<mx:columns>
<mx:DataGridColumn headerText="id" dataField="id" width="80"/>
<mx:DataGridColumn headerText="E-mail" dataField="email"/>
<mx:DataGridColumn headerText="Nome" dataField="nome"/>
</mx:columns>
</mx:DataGrid>
和这样的文本输入:
<s:TextInput x="62.6" y="9.75" width="408" id="SearchLoadlistOneInput" keyUp="SearchList()" />
但不幸的是我无法得到任何结果,并且数据网格已经有来自数据库的数据已经列出了数据它。
有谁可以帮忙吗,现在谢谢大家了
I tried using filterFunction not get any results, check out this example:
[Bindable]
public var SearchLoadlistOneDP:ArrayCollection;
public function SearchList():void {
SearchLoadlistOneDP.filterFunction = filter;
SearchLoadlistOneDP.refresh()
}
public function filter(item:Object):Boolean
{
var beginsWithString:String = SearchLoadlistOneInput.text;
return String(item["email"]).indexOf(beginsWithString) == 0;
}
And I used the datagrid like this:
<mx:DataGrid x="10" dataProvider="{SearchLoadlistOneDP}" y="49" width="891" height="408" id="listamail" creationComplete="LoadlistOne(0)">
<mx:columns>
<mx:DataGridColumn headerText="id" dataField="id" width="80"/>
<mx:DataGridColumn headerText="E-mail" dataField="email"/>
<mx:DataGridColumn headerText="Nome" dataField="nome"/>
</mx:columns>
</mx:DataGrid>
And text input like this:
<s:TextInput x="62.6" y="9.75" width="408" id="SearchLoadlistOneInput" keyUp="SearchList()" />
But unfortunately I can not any results, and the datagrid already has data from the database already has data listed on it.
Can anyone help?, Thank you all now
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的过滤函数应如下所示。我已经使用这个方法有一段时间了,没有遇到任何问题。这适用于 Flex 3 和 Flex 3。 4.
Here is what your filter function should look like. I have been using this method for awhile and have had no problems with it. This works with Flex 3 & 4.
Flex SDK 4.0.0,这对我有用:
Flex SDK 4.0.0, This works for me: