Populating a table with code

Hi
I am trying to populate a table using code and have database with a name and link that I would like to populate the table with. Could anyone help me?

My en goal is to have a table inside a repeater and filter out what is shown by what topic that is selected.
My data:


Any pointers in the right direction is appreciated.

Hi,

First you need to define your table.
Make sure the dataPath properties in your $w ( " #table1 " ). columns definition matches the field id in the collection.

Then query your data and populate the table’s rows with the result.

See code below:

$w.onReady( function () {

$w( "#table1" ).columns = [ 
    { 

“id” : “col1” ,
“dataPath” : “name” , // matches field key from collection
“label” : “Name” ,
“width” : 100 ,
“visible” : true ,
“type” : “string” ,
},
{
“id” : “col2” ,
“dataPath” : “link” , // matches field key from collection
“label” : “Link” ,
“width” : 100 ,
“visible” : true ,
“type” : “url” ,
}
];

wixData.query( "myCollection" ) 
    .find() 
    .then((res) => { 
        $w( "#table1" ).rows = res.items; 
    }); 

});