Closed powellnorma closed 1 year ago
Perhaps one could even expose the cell component somehow? In case we use:
parseAs: 'component',
dataComponent: MyComponent,
Then it would be possible to merge the logic for "display" and "sort" in one function. In my case, I calculate the price of something, and for that have to do a lookup in a global dict to find the current price.
Currently the data seems to get converted to lowercased strings, even for e.g. objects. I currently use
JSON.parse
to restore the object, and then try to remember to use lowercase instead of camelCase (even if the original object used camelCase for its attributes). Or maybe I am missing something? Thank you!
You can convert your objects to camelCase strings before passing them to PowerTable. This is unlikely to become a built-in functionality.
You can convert your objects to camelCase strings before passing them to PowerTable. This is unlikely to become a built-in functionality.
But wouldn't it make sense to give the customSort function access the original data instead of a transformed version? I mean the original values still exist in memory etc. Or are there technical reasons for why this would be hard to accomplish?
The customSort function compares two string values in order to decide the order of rows. If your original data has property values that are not strings (e.g. boolean, number, object, array) they have to be first converted to string. Because without transforming all values to strings, we might face a situation in which one side of the comparison is a nested object and the other side is an array, for example. But, I agree that we should revisit this issue once we find an efficient way to sort the original data and skip the conversion.
Ok, two ideas:
These ideas are also worth looking further into. Depending on the implementation, the trade-off might be acceptable. If you come up with ways to implement them, please share your solutions here, so that we can discuss the details.
Currently the data seems to get converted to lowercased strings, even for e.g. objects. I currently use
JSON.parse
to restore the object, and then try to remember to use lowercase instead of camelCase (even if the original object used camelCase for its attributes). Or maybe I am missing something? Thank you!