BS4 Datatable problems


#1

I’ve gone through the sample file for Datatables (BS4 in BASIC) and am getting nowhere. I’ve made an extremely cut down version of the original sample and can not for the life of me work out why it won’t show my new column names and my data.

Any help appreciated.

JavaScript
    
    var data1 = [
        ["1", "John", "2000", "100"],
        ["2", "Shane", "1000", "99"],
        ["3", "Andrew", "500", "98"]
    ];
    
    var dataJson = JSON.stringify(data1);
    
    var columns1 = [
        {title: "RANK"},
        {title: "PLAYER"},
        {title: "SCORE"},
        {title: "PTS"}
    ];

End JavaScript

Function Button1_onclick()
    dt.clear
    dt.settings.columns = columns1
    dt.settings.data = data1
    dt.build()
End Function

dt is the name of my datatable
I’ve just added a Button which I was hoping would change the datatable and put my data in it, but it really does nothing except make the datatable expand and fit the container I have it in.


#2

Problem solved, but I’m not really sure why this is necessary:

Added…

Function Main()
        Button1_onclick()
End Function 

Can anyone elaborate? Obivously the Function Main() runs before anything else - does it run when my project starts (This database is on the fourth form and is not the startup form)


#3

Function Main() is run when all loading is done. If you have a project with lots of libraries (which is certainly the case with DataTables), it’s good to wait until everything is loaded.