Dynamic Columns from async Load #56
WallaceSociety
started this conversation in
General
Replies: 1 comment 4 replies
-
Hi @WallaceSociety, thanks for the feature suggestion! I built Svelte Headless Table with static columns in mind mostly to guarantee type safety for all the plugins, so I didn’t plan for dynamic columns. However, you do bring up a pretty good point about dynamically loading columns based on loaded data. I can plan for an API extension that allows updating the view model columns, but it would most likely require recreating the view model under the hood. In the meantime, would it be possible for you to re-create the table instance on data load? Something like: let table = createTable(data, {…});
let viewModel = table.createViewModel(…);
async function loadData() {
// handle loading
const columns = …
table = createTable(data, {…});
viewModel = table.createViewModel(columns);
}
$: {headerRows, rows} = viewModel; |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm coming from Vue and as a Svelte learning exercise I'm simply trying to create a component that loads a CSV file and displays the results. Assuming the first row contains headers I would like to creating dynamic columns based on that first row.
I think I am about 90% of the way there, but I'm not sure how to go about updating the view model of the table after data has been loaded ( or changed ). Is there something to the effect of updateViewModel that I should be calling?
Beta Was this translation helpful? Give feedback.
All reactions