-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do i get Data from json array? #227
Comments
You can use the bootstrap-table-flatJSON to do this.. Here an example http://wenzhixin.net.cn/p/bootstrap-table/docs/extensions.html#flatJSON and this is the data.json used by this table http://wenzhixin.net.cn/p/bootstrap-table/docs/data5.json. |
@djhvscf Hi, does this method work on JSONP type as well? |
Yes @jl4347, this extension supports JSONP type as well. |
Yes, @jl4347 . If you need some help just ask for it!. |
@wenzhixin @djhvscf The JSONP data I need to put in the table is of the following format: “comments” attribute is an array of objects in the JSONP data,the three attributes above is one I need to show in the table, is it possible to do that in table?Although we can use flatoutJSON to flat out JSONP data, but I don't know how to pass the array into the table. Thank you very much for your time and help. |
Ok @jl4347 , I think you have to set in your table the data-flat= true and in the data-field give all the "route" to get the attribute that you want.. Like this: <th data-field="id.id2" data-align="right" data-sortable="true">Item ID</th>
<th data-field="name.name2" data-align="center" data-sortable="true">Item Name</th>
<th data-field="price.price2.price3" data-align="" data-sortable="true">Item Price</th> |
And how do I pass the JSONP data to the table, in the example it is like:
In other words, how do I pass the JSONP data from the javascript to the .html? |
You can pass the data via Javascript -> http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#via-javascript-table Of course you have to set the flat attribute in true |
@djhvscf BTW, the file I should download to use the flatoutJSON plugin is "flatJSON.min.js" right? |
Yes, you're right. And the file you have to use is bootstrap-table-flatJSON.js or bootstrap-table-flatJSON.min.js.. |
You have to download the code from https://github.com/djhvscf/bootstrap-table-flatJSON |
@djhvscf Thank you vey much, I will have a try. |
Ok. Let me know if your code works 😄 @jl4347 |
@djhvscf
This is the .js script I used to retrieve data:
|
Hi @jl4347 did you download this js file?? -> https://github.com/djhvscf/bootstrap-table-flatJSON I think that the first problem is that.. |
hi @djhvscf does this plugins work for flat json array? How do i get products.price ? Thanx for your time |
@djhvscf |
Are you calling this script in the correct order?? I mean first the bootstrap-table.js and then the extension?? @jl4347 |
@okgint You have to use the data-flat = true if you are using the tablle config with data attributes or you have to pass the flat parameter eith true if your config is via javascript.. Then you can get the price like that -> products.price |
@djhvscf your plugin still doesn't work. i have to do it manually by putting data-formatter and iterating the array. |
Ok. Let me know why the plugin doesn't work @okgint |
@djhvscf |
@djhvscf I have no idea what do I need now.... |
I tested the js file and it is working.. Can you paste your code..?? I need to review it @jl4347 |
Here's my code:
And the js code:
|
I don't see the call for bootstrap-table.js.. @jl4347 |
@djhvscf |
Are you using this bootstrap plugin https://github.com/wenzhixin/bootstrap-table?? |
Really I don´t understand what you want to do.. @jl4347 |
OK, I got rid of the errors, but still the table didn't catch anything. What I am trying to do use .ajax to retrieve data from the new york times and then pass the JSONP data to the table to display. |
Ok, first if you want to use the bootstrap-table-flatJSON you have to use the bootstrap-table plugin.. Now, If you want to use only the flatJSON plugin you have to use this js file -> https://github.com/djhvscf/flatJSON/releases/tag/v1.2.0 |
Yeah, I loaded those two files, but the bootstrap table is not catching the JSONP data |
Hi @jl4347, your JSONP format is XML?? |
@wenzhixin |
@jl4347 Try this: <table ... data-response-handler="responseHandler">
... function responseHandler(res) {
return data.results.comments;
} |
@okgint Try this: |
Close this issue. |
Hi, Can I use the flatJSON plugin to display the content of an array in one column? data.json
I wanted to display all members in one column
Thanks! |
I think you can use this example in order to get your requirement: http://issues.wenzhixin.net.cn/bootstrap-table/#issues/177.html |
Just wanted to thank @djhvscf for the helpful comments here! This hugely came in handy for me. 👍 |
Hi, How I display the content of an array created by javascript. Thanks ! |
I have a data:
[{"id":404,"description":"PowerEdge 6300","price":7500,"onhand":16,"supplierId":302,
"suppliers":[{"name":"DELL","webSite":"http://dell.com"}]}
i want to get suppliers.name field, how do i get that data field ?
The text was updated successfully, but these errors were encountered: