Setting Columns with JSON? (QUESTION/ISSUE)
See original GitHub issueIs it possible to set the columns property with JSON? Example below shows setting the data with AJAX JSON data but can it be done for the columns as well?
$table.bootstrapTable({
filterControl: true,
disableUnusedSelectOptions: true,
data: data,
height: getHeight(),
search: true,
columns: [{
field: 'selected',
checkbox: true,
align: 'center'
},
I have tried with this JSON data and no columns show up.
[
{"field":"selected","checkbox":true,"align":"center","title":null,"formatter":null,"sortable":false,"filterControl":null,"filterControlPlaceholder":null,"filterStrictSearch":false},
{"field":null,"checkbox":false,"align":"center","title":"Actions","formatter":"actionsFormatter","sortable":false,"filterControl":null,"filterControlPlaceholder":null,"filterStrictSearch":false},
{"field":"id","checkbox":false,"align":"center","title":"ID","formatter":null,"sortable":true,"filterControl":"input","filterControlPlaceholder":"Search","filterStrictSearch":false},
{"field":"cabinet","checkbox":false,"align":"center","title":"Cabinet","formatter":null,"sortable":true,"filterControl":"input","filterControlPlaceholder":"Search","filterStrictSearch":false},
{"field":"drawer","checkbox":false,"align":"center","title":"Drawer","formatter":null,"sortable":true,"filterControl":"input","filterControlPlaceholder":"Search","filterStrictSearch":false}
]
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Use column formatting to customize SharePoint
Under Column Settings, choose Format this column. ... To format a column, enter the column formatting JSON in the box.
Read more >15.10 - Examples: Inserting Values into a JSON Column
Example: INSERT Statement The example creates a table with a JSON column, allocates and initializes a JSON instance using the JSON constructor, then...
Read more >4 Creating a Table With a JSON Column
You can create a table that has JSON columns. Oracle recommends that you use JSON data type for this.
Read more >zapier integration salesforce
"it's merely a HTTP POST to the URL of client API, and send JSON ... For example, receiving an email or creating a...
Read more >Creating columns from JSON - KNIME Analytics Platform
I'm working with a JSON file structured like this: I want to be able to write to a table where the “@k” values...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great! @cgountanis
Confirmed it seems to be accepting the JSON via JS and populating the columns and data properly now.
Primitive example in case someone stumbles on this. Keep in mind the JSON has values needed for the column filter control which you might not need.
In a perfect world you would most likely want to combine the data and columns into one JSON call for timing reasons rootObject.data/rootObject.columns but you get the point. Example data JSON: https://api.myjson.com/bins/r8nya Example columns JSON: https://api.myjson.com/bins/zkqf6
Since then though we have decided to use JSON for the DATA in the HTML (data-url) and just dynamically create the THEAD part of the HTML to save some headaches. Using JS just for the client side logic as most of the examples have.
Good fix though for the next release in case someone wants to dynamically specify data and columns via JSON within JS directly though! Thank you…