Saulis / iron-data-table

iron-data-table is a Web Component for displaying data as a table or grid. Built on top of iron-list using Polymer.
Apache License 2.0
147 stars 65 forks source link

Filtering of null values #168

Closed lluisgener closed 7 years ago

lluisgener commented 8 years ago

When a column has a null value, ArrayDataSource filtering raises an exception. I have fixed it faking an empty string value to the value variable when it's null or undefined.

return Array.prototype.filter.call(items, function(item, index) {
  for (var i = 0; i < filter.length; i++) {
    var value = Polymer.Base.get(filter[i].path, item);

    /*FIX START*/
    if(value == null || value == undefined)
        value = "";
    /*FIX END*/

    if ([undefined, null].indexOf(filter[i].filter) > -1) {
      continue;
    } else if (value.toString().toLowerCase().indexOf(filter[i].filter.toString().toLowerCase()) === -1) {
      return false;
    }
  }
  return true;
});
hankphung commented 8 years ago

Meet same error here +1 I've fallback to v1.0.3 to avoid this bug.

Saulis commented 7 years ago

Thanks!

Should be now fixed in the v1.0.5

lluisgener commented 7 years ago

I think it's not correctly fixed. I still have not found what's wrong, but I see no rows at all with the array-datasource fix. I think it's related to empty strings.