ng-table filter with nested properties

柔情痞子 提交于 2019-12-05 12:58:49

When you try to use filter="{Data:{Str1: 'text'}}" in html,input doesn't showing cause of template in header,have a look in source code.

<div ng-repeat="(name, filter) in column.filter"> //!!!! right here it's not supported
        <div ng-if="column.filterTemplateURL" ng-show="column.filterTemplateURL">
            <div ng-include="column.filterTemplateURL"></div>
        </div>
        <div ng-if="!column.filterTemplateURL" ng-show="!column.filterTemplateURL">
            <div ng-include="'ng-table/filters/' + filter + '.html'"></div>
        </div>
    </div>

right here <div ng-repeat="(name, filter) in column.filter"> it's not dig into nested objects

Ngtable not support nested filter in default template,so you can create your own template,which gonna support it.Have a look to example of header template.

Note

This how column.filter is initializing,it's parsing from filter attribute on td tag,source

var parsedAttribute = function (attr, defaultValue) {
                        return function (scope) {
                            return $parse(el.attr('x-data-' + attr) || 
                                          el.attr('data-' + attr) || 
                                          el.attr(attr))
                                (scope, {
                                $columns: columns
                            }) || defaultValue;
                        };
                    };

                    var parsedTitle = parsedAttribute('title', ' '),
                        headerTemplateURL = parsedAttribute('header', false),
                        // here
                        filter = parsedAttribute('filter', false)(),
                        filterTemplateURL = false,
                        filterName = false;

                    ...
                    columns.push({
                        ....
                        filter: filter,
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!