Closed atinder closed 8 years ago
Hi!
When using a function dataSource
, you will need to always provide your own filtering and sorting functionality. I'm assuming you're using an array placed in items
, which effectively gets wrapped into a function using array-datasource.js.
The array datasource doesn't expose any functions to customize the sorting, but you can have a look how it's implemented to provide your own function dataSource
which provides the timestamp sorting you're looking for.
thanks for help. I have tried over riding dataSource but seems like its is still using array-datasource. I suspect this line https://github.com/Saulis/iron-data-table/blob/master/iron-data-table.html#L732
EDIT: This helped me getting started with custom data source, in case somebody else is looking for it https://github.com/Saulis/iron-data-table/blob/8a27b9e6e9c1c86c8924882d2a6f3102c4df2e1d/demo/index.html
@atinder90 yes, you can't use items
and dataSource
at the same time, only one of them.
yes things are becoming clear now. Is there any way to disable mutisort thing. I want my to sort based on 1 column at a time. I wrote custom logic for sorting but arrows are still highlighted after I click sort on 2-3 columns.
There's an PR #143 which is still on-going, but meanwhile you might need to modify the sortOrder from outside whenever it changes to prevent the arrows in multiple columns from sorting.
thanks, I have implemented custom data source and its working great.
I have a global search field for all columns, but it doesn't trigger custom data source (where I have searching implemented) until I interact with data table.
setting auto-refresh="1"
didn't helped either.
@atinder90 can you provide some code how you've implemented the search field?
<paper-input
id="search"
name="search"
label="Search"
value="{{search::input}}"
type="text">
</paper-input>
<iron-data-table auto-refresh="1" data-source="[[ dataSource ]]"... />
dataSource(opts, cb) {
if (this.get('search')) {
this.listItems = this.listItems.filter(item => {
//return true/false
}
}
cb(this.listItems);
}
Right, well normally when the column.filterValue
of any column changes the dataSource
gets refreshed. In this case, you need to manually call table.clearCache()
when the value
of your input changes.
thanks that did the job. Amazing :)
Hi, Does this support sorting using custom function, I need to sort timestamp column. currently it is sorting it on string basis.