How do I correctly set the columns logic in a datatable block

I am trying to run a query that will return three columns of a table and show the results in a datatable, but I am getting this error

I used databinding on Columns Logic for the datatable

I have verified each column in the list above does exist in the table.

I have also tried this without the column block above and still get the same error.

here is how i set the table name for the datatable
image

where Table Name Logic is bound to “table_name”

I’m not sure how to attack this problem.

thanks for your time,
H

1 Like

Hello @hharrington

You must ensure that are columns are provided. In your case, before you assign columns to Page Data, table was trying to access this property, and it’s undefined for that moment.

Also, I should prevent the second mistake that will appear on your way. Try to print table component like below to see how columns list should looks.

image
(don’t forget to add an ID for table component)

Regards, Dima.

I set pagedata-> columns on page entry. how should I set the columns I need before the datatable tries to access it? for that matter how do I set the table I want it to use before the datatable tries to use it?

There is two way. Using On Before Page Enter handler. Or you could hide the table(display=false) until your columns will be ready.

I set display = false, made updates to the table, then set to visible but I still get nothing on the display.

so I tried just hard coding the table name as a binding which did show my rows (no surprise there )

I have a database table, I want to pull three columns and run a where statement against it and display the results in a table. is the datatable block not the correct way to go about doing this?

after I hard coded the datatable to the database table from the ui table sector I get this.

from this it looks like it I need to send definitions for all the columns in the table. is the correct format to do this to create a list of objects each contained within {} and using , between fields?

list ->  object 1    {title: 'field title', field: 'column name', editable: true, searchable: true, sortable: true}
         object 2    {title: 'field title', field: 'column name', editable: true, searchable: true, sortable: true} 

when I tried that it showed as a proxy array and it looks like a string

while the datatable with no data bindings looks like this

I’m not sure what I am doing wrong.

H

Columns it is a list of objects, not a string.

So your approach(shown below) is not correct

Here is a guide how to work with objects - https://www.youtube.com/watch?v=sWsk4qaWVMg

Regards, Dima.