Default value for filter - filterString
The property "filterString" seems to be unused. According to the documentation, I thought this property would be used to set the default value of a search field. In this example, I set a value, but I can't find it anywhere.
COLUMNS: [
{ title: 'name', name: 'name', filtering: { filterString: 'MY DEFAULT VALUE', placeholder: 'Filter by name' } },
{ title: 'comments', name: 'comments', filtering: { filterString: '', placeholder: 'Filter by comments' } },
{ title: 'date', name: 'date' },
{ title: 'typeName', name: 'typeName' },
]

I found this piece of code, but I don't really understand how it works..
function NgTableFilteringDirective(element, renderer) {
this.ngTableFiltering = {
filterString: '',
columnName: 'name'
};
this.tableChanged = new core_1.EventEmitter();
this.element = element;
this.renderer = renderer;
// Set default value for filter
setProperty(this.renderer, this.element, 'value', this.ngTableFiltering.filterString);
}
And in this code, the input search doesn't contain the "value" property.
<input *ngIf=\"column.filtering\" placeholder=\"{{column.filtering.placeholder}}\"\n [ngTableFiltering]=\"column.filtering\"\n class=\"form-control\"\n style=\"width: auto;\"\n (tableChanged)=\"onChangeTable(config)\"/>\n
Finally, is there a way to define a value to the input or what am I doing wrong ?
Yes i have came across this issue. Although the config has the filterString set the input doesnt show the text in it.
any solution to this one?
Yes, the ng-table-component.ts class needs to be changes slightly: the input tag for the filter string needs to have this added: value="{{column.filtering.filterString}}". I will try and create a PullRequest for this.