AngularJS多个列中的智能表搜索 [英] AngularJS smart-table search within multiple columns

查看:190
本文介绍了AngularJS多个列中的智能表搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

智能表有一个内置的功能,通过一个所需的列(ST-搜索='的firstName')通过所有列(ST-搜索)或者搜索。是否有可能做几列中进行搜索(不是全部)?
例如:如果我有表是这样的:姓名,昵称,地址这样的数据:

Smart-table has a built in functionality to search through all columns (st-search) or through one desired column (st-search="'firstName'). Is it possible to do a search within several columns (not all)? Example: if I have table like this: name, nickname, address with such data:


  1. 约翰,JJ,有些地址

  2. 史蒂夫,约翰,还解决了

  3. 简,简,约翰村

和做'约翰'只有前两列应作为结果的搜索。
这可能吗?

and do a search for 'John' only first two columns should be as result. Is it possible?

推荐答案

不,一个解决方法是创建您自己的指令,它要求表控制器和两次调用其API(如搜索得到补充)

Nope, a workaround is to create you own directive which require the table controller and call its api twice (as the search get added)

directive('stSearch', ['$timeout', function ($timeout) {
    return {
        require: '^stTable',
        scope: {
            predicate: '=?stSearch'
        },
        link: function (scope, element, attr, ctrl) {
            var tableCtrl = ctrl;

            // view -> table state
            element.bind('input', function (evt) {
                evt = evt.originalEvent || evt;
                tableCtrl.search(evt.target.value, 'column1');
                tableCtrl.search(evt.target.value, 'column2');
            });
        }
    };
}]);

你会发现在 stSearch direcitve

这篇关于AngularJS多个列中的智能表搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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