Skip to content
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

[Grid.js] [ERROR]: Could not determine the storage type #26

Open
alphonso06 opened this issue Aug 17, 2022 · 1 comment
Open

[Grid.js] [ERROR]: Could not determine the storage type #26

alphonso06 opened this issue Aug 17, 2022 · 1 comment
Labels
out-of-scope question Further information is requested

Comments

@alphonso06
Copy link

Hello,

I'm trying to set the data for the table using fetch() but I get [Grid.js] [ERROR]: Could not determine the storage type as an error.

I'm aware you have to use the server prop to set the data that way (as seen in this REPL). But my use case requires that I use my own HTTP client - the one I wrote automatically renews authentication on 401 responses.

I ask if there's a way to set the table data dynamically without using the server prop? Currently I'm testing using fetch() on jsonplaceholder which matches the format of the data in the Svelte example REPL. This results in the aforementioned error message on compile.

I've also seen the Custom HTTP Client section of the documentation but I'm unsure how I can create something reusable, especially since I'll be calling a lot of dynamic columns from different endpoints.

Perhaps a way to set the data using writable stores? Or maybe I'm missing something and this is already possible?

Thanks in advance. 😁️

@iamyuu iamyuu added question Further information is requested out-of-scope labels Oct 27, 2022
@HubertKaluzny
Copy link

HubertKaluzny commented Apr 7, 2023

Error comes from here: https://github.com/grid-js/gridjs/blob/51e0818aff399c7151eb7bc363246e44acad1bbd/src/storage/storageUtils.ts#L32

Need to ensure your storage/data property isn't undefined/null when instantiating the component (occurred for me when I was statically prerendering the site).

E.g statically building this:

<script>
    import { onMount } from 'svelte';
    import Grid from 'gridjs-svelte';
  
    let data;
    onMount(async () => {
        // dynamically load values into data array
        data = [1, 2, 3, 4];
    });
</script>

<Grid data={data} />

Will fail as the data property is undefined and grid-js can't determine what the storage type it is.

Whereas here the site builds fine:

<script>
    import { onMount } from 'svelte';
    import Grid from 'gridjs-svelte';
  
    // instantiate with empty array
    let data = [];
    onMount(async () => {
        // dynamically load values into data array
        data = [1, 2, 3, 4];
    });
</script>

<Grid data={data} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
out-of-scope question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants