多选搜索整个字符串 [英] Multiselect search whole string

查看:193
本文介绍了多选搜索整个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索绑定到商店的多重选择(带有属性string_value)。搜索只搜索以string to search开头的字符串,而不是包含要搜索的字符串(类似于搜索'%string%'而不是'string%')。是否有办法通过扩展多选择器搜索?

I have a multiselect with search bound to a store (with attribute string_value). Search only searches strings that start with "string to search" instead of contains "string to search" (similar to searching for '%string%' instead of 'string%'). Is there a way to do this by extending 'multiselector-search'?

以下是我的多重选择器控件绑定到一个窗体:

Below is my multiselector control bound to a form:

var ms = Ext.widget('form', {
    xtype: 'multi-selector',
    width: 400,
    height: 300,
    requires: [
    'Ext.view.MultiSelector'
    ],
    layout: 'fit',

    renderTo: Ext.getBody(),
    items: [{
        bbar: [{
            xtype: 'button',
            itemId: 'button',
            html: 'Toolbar here',

            text: 'Submit request to API',

            // get submitted array
            handler: function() {
                if (cardioCatalogQT.config.mode === 'test') {
                    console.log('In submitted values handler: ');
                }

                var submitted = Ext.getCmp('test');

                var dx = [];
                Ext.Array.each(submitted.store.data.items, function (item) {
                    dx.push(item.data.string_value);
                }); // each()

                Ext.Msg.alert('Submitted Values',
                   'The following diagnoses will be sent to the server:  <br      
                />' + dx);

                if (cardioCatalogQT.config.mode === 'test') {
                    console.log(dx);
                }
            }
        }],
        xtype: 'multiselector',
        title: 'Selected Dx',

        id: 'test',
        name:'test',
        fieldName: 'string_value',

        viewConfig: {
            deferEmptyText: false,
            emptyText: 'No Dx selected'
        },
        // TODO: fix ability to remove selected items when box is unchecked
        search: {
            field: 'string_value',
           store: 'Diagnoses'

        }
    }]
}).center();

最近我找到这个问题是 http://www.sencha.com/forum/showthread.php?240887 。我试着让它与多重搜索一起工作,没有成功。

The closest I could find to this problem was http://www.sencha.com/forum/showthread.php?240887. I tried making it work with the multiselect search with no success.

推荐答案

MultiSelector使用Ext.util.Filter来缩小结果基于打字文本。您需要启用 anyMatch 属性,以便在任何地方匹配。

The MultiSelector uses the Ext.util.Filter to narrow the results based on the typed text. You need to enable the anyMatch property for it to match anywhere.

为此,您必须在多重选择器的搜索对象中添加一个新的搜索功能,将有anyMatch = true。

To do that, you'll have to include a new "search" function in your multiselector's search object that will have anyMatch=true.

请看我的小提琴, https://fiddle.sencha.com/#fiddle/jf5 ,有关如何执行此操作的示例。

Please see my fiddle, https://fiddle.sencha.com/#fiddle/jf5, for an example of how to do this.

这篇关于多选搜索整个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆