wdkrnls
December 19, 2015, 3:21am
1
Can someone give me an example of how to populate a data table from an external JSON file?
For example, I’d like to display a data table of Old Faithful eruptions:
http://public.opencpu.org/ocpu/library/datasets/data/faithful/json
I was hoping it would be as easy as:
`
webix.ui({view:"datatable",
columns: [
{id: "waiting", header:"Waiting", width: 80 },
{id: "eruptions", header:"Eruptions", width: 80 }
],
url = "http://public.opencpu.org/ocpu/library/datasets/data/faithful/json",
autowidth:true
});
`
But nothing happens. Do I need to make an ajax request somehow?
wdkrnls
December 19, 2015, 6:22pm
3
Thanks! That works. The following works also.
`
var faithful = webix.ajax("http://public.opencpu.org/ocpu/library/datasets/data/faithful/json");
webix.ui({
cols:[
{ rows:[ { view:"datatable", autoConfig:true, data:faithful }]}
]});
`
i tried http://webix.com/snippet/7c7471a0 but the data is not loading
Works if you remove the “http:” from the url.
https://snippet.webix.com/pct7cpgj
@prasadraju
use this
url:"//public.opencpu.org/ocpu/library/datasets/data/faithful/json"
Is it possible to read specific variable data from json file instead of reading complete json file data for webix datatable?
for ex: If i want data from VAR2 variable content for my datatable if json file contains below information:
{VAR1:[
{ “id”:1, “title”:“The Shawshank Redemption”, “year”:1994, “votes”:678790, “rating”:9.2, “rank”:1},
{ “id”:2, “title”:“The Godfather”, “year”:1972, “votes”:511495, “rating”:9.2, “rank”:2}
],
VAR2:[
{ “id”:1, “title”:“The Shawshank Redemption”, “year”:1994, “votes”:678790, “rating”:9.2, “rank”:1},
{ “id”:2, “title”:“The Godfather”, “year”:1972, “votes”:511495, “rating”:9.2, “rank”:2}
]
}
Dzmitry
September 11, 2019, 2:56pm
9
Hey @ganeshkp , are you talking about something like this - https://snippet.webix.com/urdp612c , or is it something different?
@Dzmitry But same content will be in external json file. How to get that data if we use url to read json file.
Dzmitry
September 12, 2019, 9:11am
11
In this case you should form a request to get the specific data from your server, it really depends on how your environment is set up.
If you are unable to do so, the only way to do this on the client side is by manually parsing the selected data after making the request, for example: https://snippet.webix.com/2mywehwq .
@Dzmitry Thanks for help.