Trying to display user details using ember-models-table addon. Also wanted to filter the data using a isActive field .Am using ember computed property for that (filter). First time when the page is loading am getting the correct result.But when i try to filter , i could see value for currentfilter is passed correctly but am not getting any results. The table says no records to show.
My .hbs code:
<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
}}
My controllers code:
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);
}
}
Please help.
After checking , i just noted it was a silly mistake, the filterUpdated method returns string and isActive field needs a boolean value. I just included the follwing line to change it to boolean.
var isActiveS = (this.get('currentFilter') == 'true');
It worked.