aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 138 forks source link

how to turn off default sorting on load ? #437

Open nowshad-sust opened 7 years ago

nowshad-sust commented 7 years ago

I want to keep the sorting functionality on. But the table sorts on a column by default on load. But I want to keep the order as it came from the database. Is there any way to do that. for normal datatables there are options to disable this feature. But is there any way ?

aslagle commented 7 years ago

The table is always sorted by some column, but you could use a hidden column for _id as the default sort if you don't want it to be in the table.

nowshad-sust commented 7 years ago

that's sad. I've already sorted my data and now the table forcefully sorting it again !

aslagle commented 7 years ago

Unless your data's in an array, I don't know what it means for it to be already sorted. You can't rely on the sort order from Collection.find unless you specify a field to sort by.

nowshad-sust commented 7 years ago

yes, my collection.find({}) method was already sorting data by two attributes, then the table gets all messed up :-(

aslagle commented 7 years ago

you should be able to get the same sorting by giving the table the collection and adding sortOrders to the appropriate columns. passing in collection.find is more useful for filtering the collection before it gets to the table, but if you need that too you can also set up a filter for the table.

nowshad-sust commented 7 years ago

are you saying I need to make a filter to do nothing ! I just need to disable the default sorting, there should be an option like datatables had. There were options like aaSort or others that could be just assigned false to turn off the default sorting.

aslagle commented 7 years ago

If you like datatables you'd probably prefer the aldeed:tabular package.

But to answer your question, you don't have to make a filter if you didn't have one before.

If your table settings were something like

collection: myCollection.find({}, {sort: {a: 1, b:1 }}),
fields: ['a', 'b']

you could change it to

collection: myCollection,
fields: [{ key: 'a', sortOrder: 0}, {key: 'b', sortOrder: 1}]

and you would get the same sorting.

I was thinking if you had myCollection.find({c: 'something'}, {sort: {a: 1, b:1 }}) you would need to switch to a filter, but actually I think it would still work with the cursor and the sortOrders in the fields.

nowshad-sust commented 7 years ago

another question, I just changed my theme of the webpage which included reactive table- but now the numbers in the page number fields are not shown, can I override their styling ?

aslagle commented 7 years ago

Yeah, you'd need to find the selector from the style that's currently hiding them and add a more specific selector that shows them - putting .reactive-table-navigation before it might work.

nowshad-sust commented 7 years ago

great support. thank you. managed to override the styles. But, I made my sorting thing working, but still not an efficient way. It will be a better option if there's an option for turning off the default sorting at the table on load.

genjurosama commented 7 years ago

I'm experiencing the same probleme , and i'm not using a collection at all just an array that i receive from the server side ! i have some big computations to do ! since i'm using the reactive table as a reporting display tool with pagination ! not sure if i should be using this package in the first place .