Click here to Skip to main content
15,029,206 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm still new to Javascript and HTML, I'm trying to create a table to display reports extracted from firebase RT Database.

I'm Getting the following Error:

Uncaught TypeError: this.options.data.slice is not a function
at Tabulator._clearObjectPointers (tabulator.js:9532)
at Tabulator._create (tabulator.js:9488)
at new Tabulator (tabulator.js:8715)
at tableCreator (index.html:705)
at index.html:804
at EventRegistration.ts:133
at kt (util.ts:588)
at jr.raise (EventQueue.ts:171)
at Vr.raiseQueuedEventsMatchingPredicate_ (EventQueue.ts:123)
at Vr.raiseEventsForChangedPath (EventQueue.ts:103)


any help please

What I have tried:

JavaScript
//below is a sample data which looks typically the same extracted from firebase

            var jsonData =
            {
                availability: {
                    supermarket01: {
                        '2342342': {
                            green100: 'no',
                            green200: 'yes',
                            red200: 'yes',
                            yellow: 'no',
                            purple100: 'yes',
                            cyan100: 'no'
                        },
                        '58943792': {
                            green200: 'yes',
                            orange200: 'yes',
                            red200: 'no'
                        },
                        '398489593': {
                            green200: 'no',
                            orange200: 'no',
                            red200: 'yes'
                        },
                        '1605290957000': {
                            orange: 'yes',
                            green2123: 'no',
                            green222: 'yes'
                        }
                    },
                    supermarket02: {
                        '23423423': {
                            green200: 'yes',
                            orange200: 'no',
                            red200: 'no'
                        },
                        '23947928': {
                            green200: 'yes',
                            orange200: 'no',
                            red200: 'yes'
                        }
                    }
                }
            }

                const table = new Tabulator("#example-table", {
                    layout: "fitColumns",
                    autoRows: true,
                    dataTreeChildField: "childRows",
                    autoColumns: true,
                    dataTree: true,
                    resizableColumns: false,
                    data: jsonData,
                    selectable: true,
                });

HTML
<div id="example-table"></div>
Posted
Updated 9-Dec-20 5:18am
Comments
BabyYoda 9-Dec-20 10:20am
   
I don't believe there is enough information for us. The errors says that slice is not a function which means somewhere there is code calling slice but it does not know where to get it. I don't see it anywhere that you posted so I don't think you have posted the relevant code.
Ammar9191 9-Dec-20 10:24am
   
I believe slice is a function or a variable in tabulator library, it's not in my code. to reproduce you will need to include this library as well.
BabyYoda 9-Dec-20 10:46am
   
Then you might not be including other libraries that it depends on or are missing an option when loading it. No way to tell.
Ammar9191 9-Dec-20 10:58am
   
ok, maybe I missed to say in the question that this same code works ok for other JSON format, but for my particular JSON it's not able to work. if you're familiar with Tabulator library you will understand the question right away.
BabyYoda 9-Dec-20 11:17am
   
It likely means your data is not in the right format.

1 solution

According to the documentation the data option should be an array, not a json string, Tabulator[^].

Try the example in the documentation and it will likely work.
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900