reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

how to turn off default sorting on load ?

Open nowshad-sust opened this issue 9 years ago • 11 comments

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 ?

nowshad-sust avatar Oct 07 '16 11:10 nowshad-sust

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.

aslagle avatar Oct 08 '16 20:10 aslagle

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

nowshad-sust avatar Oct 09 '16 07:10 nowshad-sust

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.

aslagle avatar Oct 09 '16 14:10 aslagle

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

nowshad-sust avatar Oct 10 '16 13:10 nowshad-sust

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.

aslagle avatar Oct 13 '16 23:10 aslagle

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.

nowshad-sust avatar Oct 15 '16 10:10 nowshad-sust

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.

aslagle avatar Oct 16 '16 17:10 aslagle

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 ?

nowshad-sust avatar Oct 20 '16 20:10 nowshad-sust

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.

aslagle avatar Oct 20 '16 23:10 aslagle

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.

nowshad-sust avatar Oct 21 '16 11:10 nowshad-sust

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 .

genjurosama avatar Dec 21 '16 12:12 genjurosama