fivem scripting I'm working on a table NUI how would i create a table and then get data…
- User
fivem scripting
I'm working on a table NUI how would i create a table and then get data from a format like this {[1] = {['name'] = 'BOB', ['age'] = 18}} and show that data on the NUI
- Assistant
To create a table in the NUI and display the data from a table formatted like the one you provided, you'll need to follow these steps:
-
Create an
htmlfile for your NUI, let's call ittableNUI.html. -
Add the necessary HTML structure in the
tableNUI.htmlfile:
-
- User
how would I do it with jquery DataTables and use bootstrap to style it
- Assistant
- User
do it without bootstrap styling
- Assistant
To use jQuery DataTables without Bootstrap styling, you just need to remove the Bootstrap CSS and update the classes in the table element.
- Remove the Bootstrap CSS link from the
headsection oftableNUI.html:
<!-- Remove this line --> <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">-->- Update the table structure in the
bodysection oftableNUI.htmlto remove Bootstrap classes:
<!-- Remove "table table-striped table-bordered" classes --> <table id="myTable" style="width: 100%;"> <thead> <tr> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> <!-- The table data will be added here using DataTables --> </tbody> </table>- The JavaScript code and the FiveM script remain the same as in the previous example, no need to change them.
After these changes, your NUI table will use jQuery DataTables without the Bootstrap styling. You may want to apply custom styles to the table since the default DataTables styling is relatively basic.
- Remove the Bootstrap CSS link from the