Adding Tabulator.js and Changing Template

Hello,

I am new to BootStrap Studio. I went through all of the tutorials and forums and cannot find answers to a couple of questions.

  1. How do I add Tabulator.js to a page I am creating? I downloaded the package and imported the .css and .js files. I created the example-table data logic based on a tabulator tutorial. The logic was saved to an example.js file. Afterward, I added the required div to my page as:

<div id="example-table">Test Tabulator</div>

(I tried without the caption too). Nothing shows up on the page nor in the Preview browser window. Tabulator Website 2. Is it possible to change the main Style sheet after creating the project to another style template? I was watching a BootStrap Studio tutorial and it appears there used to be a button on the toolbar that allowed this functionality. I am using the latest version 4.5.7.

Any help with these two questions would be greatly appreciated!

Ben

Without actually "trying" to work it out myself it's hard to know for sure, but the first place I would start is in your file order on the page. You can reorder the JS and CSS files as needed (always making sure your custom CSS files are at the bottom, and your custom JS files are at the top). Just go over into the Design pane on the right and right click over either Styles or Javascript and you'll see a choice called "Include Order ..". Choose that and it will open a dialog box that allows you to reorder the files as needed.

The order doesn't show up correctly in the Design pane so you can't really go by that, that area is all alphabetical. Once you have them rearranged as needed, check again and see if your Tabulator shows up.

Do be sure all the files/code that is necessary is added. It's easy to sometimes forget to add something in. Also, very seldom will things like this work within BSS, but all should work in the Browser Preview as long as it's been imported into BSS.

That's all I can think of to try for now without actually trying to put it in myself.

Thank you for the tips but no joy. I created a dummy project and ensured the CSS and js files were in proper order using your suggestion. Perhaps this is a dependency issue. I will attempt to publish the project and debug to see if I can track down why the component is not working.

If there are any other ideas, I would appreciate it!

Also, my other question was about the CSS templates. Is there a way without recreating a project to apply a different template?

Thanks!

Ben

Resolved in my test project. There were additional .js dependencies that were required by this component.

Styles tabluator_bootstrap5.min.css

JavaScript tabulator.js, tabulator_core.min.js, tabulator.min.js

Add a JavaScript file, add the code to populate a JSON data element, create and configure the Tabulator component based on examples from tabulator.info and call the function: table.setData(tableData); (tableData being the JSON array of data details)

Sample JS file

  var tableData =
[
    {id:1, name:"Billy Bob", age:"12", gender:"male", height:1, col:"red", dob:"", cheese:1},
    {id:2, name:"Mary May", age:"1", gender:"female", height:2, col:"blue", dob:"14/05/1982", cheese:true},
    {id:3, name:"Christine Lobowski", age:"42", height:0, col:"green", dob:"22/05/1982", cheese:"true"},
    {id:4, name:"Brendon Philips", age:"125", gender:"male", height:1, col:"orange", dob:"01/08/1980"},
    {id:5, name:"Margret Marmajuke", age:"16", gender:"female", height:5, col:"yellow", dob:"31/01/1999"},
    {id:6, name:"Billy Bob", age:"12", gender:"male", height:1, col:"red", dob:"", cheese:1},
    {id:7, name:"Mary May", age:"1", gender:"female", height:2, col:"blue", dob:"14/05/1982", cheese:true},
    {id:8, name:"Christine Lobowski", age:"42", height:0, col:"green", dob:"22/05/1982", cheese:"true"},
    {id:9, name:"Brendon Philips", age:"125", gender:"male", height:1, col:"orange", dob:"01/08/1980"},
    {id:10, name:"Margret Marmajuke", age:"16", gender:"female", height:5, col:"yellow", dob:"31/01/1999"},
]

var table = new Tabulator("#example-table", {
    height:"311px",
    columns:[
    {title:"Name", field:"name"},
    {title:"Age", field:"age", align:"right", sorter:"number"},
    {title:"Gender", field:"gender"},
    {title:"Height", field:"height", align:"center", sorter:"number"},
    {title:"Favourite Color", field:"col"},
    {title:"Date Of Birth", field:"dob", align:"center", sorter:"date"},
    ],
});

table.setData(tableData);

I would attach some screenshots but this forum disallows unless it is a link to a public website which I do not have.

Thanks again!

Ben

You're quite welcome, glad it was a simple fix! Good luck and enjoy the program, I know I have now for over 3 years. :)

Also, my other question was about the CSS templates. Is there a way without recreating a project to apply a different template?

If you mean can you build a site from a template, and then switch to a different template and have everything "adopt" the CSS of the new template, then the answer is, "no." This program doesn't work like that.

However, if you create your own site using your own custom CCS classes, you could theoretically create different stylesheets that style those classes in different ways, and then by simply importing your own custom stylesheets, you would be able to change your site as if it were a template. So one site could have many different looks (fonts, colors, spacings, etc...)

You should also look into using components. It's very easy to save entire pages as a component, and you can easily make components with different styles/appearances and then just drag them into your sites as needed. I have a very large personal library of components I use in this fashion.

Hi!

Thanks for the info, this solved the same issues for me, works like a charm now!

/ Totte