使用 ember computed 属性(filter) 过滤模型并使用 ember-models-table 2 以 table 格式显示。它没有记录显示

Using ember computed property(filter) to filter model and using ember-models-table 2 for displaying in table format. It gives no record to show

尝试使用 ember-models-table 插件显示用户详细信息。还想使用 isActive 字段过滤数据。为此使用 ember 计算 属性(过滤器)。第一次加载页面时,当我尝试过滤时得到正确的 result.But,我可以看到正确传递了 currentfilter 的值,但没有得到任何结果。 table 表示没有要显示的记录。

我的 .hbs 代码:

    <div class="form-group">
        <label for="show">Show:</label>
        <select class="form-control" id="show" onchange={{action "filterUpdated" value="target.value"}}>
            <option value="null">All</option>
            <option value="true">Active</option>
            <option value="false">Inactive</option>
        </select>
    </div>

    {{models-table
data=filteredPeople 
columns=columns 
showColumnsDropdown=false 
useNumericPagination=true 
filteringIgnoreCase=true 
showPageSize=true
    }}

我的控制器代码:

 users: alias('model'),
currentFilter: null,

filteredPeople: filter('users', function(user) {

  if(this.get('currentFilter') === null) {
    return true;
  } else {
    return user.isActive === this.get('currentFilter');
  }
}).property('users', 'currentFilter'),

actions: {

  filterUpdated: function (value) {

    alert(value);
    if (value=== null) {
      this.set('currentFilter', null);
    }
    else {
      this.set('currentFilter', value);
    }
  }

请帮忙。

检查后,我只是注意到这是一个愚蠢的错误,filterUpdated 方法 returns 字符串和 isActive 字段需要一个布尔值。 我只是包含了以下行以将其更改为布尔值。

var isActiveS = (this.get('currentFilter') == 'true');

成功了。