New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to disable hide / improved hide column API #140
Comments
Hey @huntabyte! I figured that since the hidden column ids state was just a Since the state is fully controlled by you, I didn't think you'd need a And I'm wary of adding more API to this library as it is getting a little ridiculous. My suggestion would be to do something in native "Svelte" like:
Of course, let me know if there's a better approach I should use! |
Ah gotcha, consistency is definitely something that'd be nice. I'll work on this for the next patch version. |
Hi, what is the current option to have certain columns hidden by default? I tried to use the
I'm using @huntabyte 's example of a table from 'shadcn-svelte'. His select option works, but by default it displays all the hideable columns even if I add a column to the 'addHiddenColumns' (as shown above) or manually to the hidden columns store
Thanks |
Ok, you can scratch all I said above. I found a way. For anyone who might need in the future. I changed the 'hideForId' var
|
The approach above created another problem for me. Now if I want to use a column interactively and use its value in creating a URL to click on, it MUST be visible. This is usually impractical as for a URL/route construction one usually needs an id or code but in the table we only show a description of the product. |
In my scenario I made the data table as a component then customise it when i import it, so to have coloums hidden on init, I added the following to my export let preHiddenColumns: string[];
let hideForId = Object.fromEntries(
ids.map((id) => (preHiddenColumns.includes(id) ? [id, false] : [id, true])),
); Then in my component where I import it: <script lang="ts">
import DataTable from "$lib/DataTable";
...
</script>
<DataTable preHiddenColumns={[ "address", "username" ]} {...otherVariables} /> |
Thanks @lewisjr , but I have already found a solution. It turns out there is an option Thanks |
I'm not able to see any options to disable the "hide" plugin for specific columns as we can for others, is this something on the roadmap? I may be able to submit a PR to support this.
I think it'd also be possible to expose a helper function that takes an id and toggles the hidden state of the column so it's cleaner.
The text was updated successfully, but these errors were encountered: