Please, I need acess a third party .json file that is supplied as array of objects (name value pairs). Access to this data will be transactional (supplier offer some APIs options). Instead of doing via pure Jscript, it would be more pratical if once I have the json text buffer in hands, I could parse it (or whichever else) into some webix component(maybe tree), so I can than manipulate as object data.
Basically, you can load JSON from wherever by
someview.load("url")
But you can also store the data in the DataCollection or in the TtreeCollection and just parse the data when needed.
Thanks…That is exacly what I was trying…but I get only a line with text “undefined”. follow the container code:
var envtree = webix.ui({
container:"envbody",
id:"env",
view:"tree",
});
function LoadData()
{
$$("env").load("city3.json", "json");
}
and the json data aquired from a wheather supply. I can read it visualize it perfectly as a tree using in any json viewer/editor.
{
"city": {
"id": 524901,
"name": "Moscow",
"coord": {
"lon": 37.615555,
"lat": 55.75222
},
"country": "RU",
"population": 0,
"sys": {
"population": 0
}
},
"cod": "200",
"message": 0.0043,
"cnt": 40,
"list": [
{
"dt": 1467309600,
"main": {
"temp": 295.65,
"temp_min": 295.65,
"temp_max": 297.515,
"pressure": 1008.94,
"sea_level": 1028.35,
"grnd_level": 1008.94,
"humidity": 37,
"temp_kf": -1.86
},
"weather": [
{
"id": 803,
"main": "Clouds",
"description": "broken clouds",
"icon": "04d"
}
],
"clouds": {
"all": 64
},
"wind": {
"speed": 1.72,
"deg": 2.50436
},
"sys": {
"pod": "d"
},
"dt_txt": "2016-06-30 18:00:00"
}]}
By default, tree expexts value
attribute as an actual value and data
array for children. Please check the related description.
So you need to customize the datatype and specify the data template.
Here’s the Docs:
http://docs.webix.com/desktop__custom_data_types.html
http://docs.webix.com/helpers__data_drivers.html
And also a sample
into some webix component(maybe tree)
Actually, the current dataset is suitable for ui.form (check the complex data chapter, the structure of the dataset is the same).
With some customization, it is possible to embed the datatable into the form, if needed.
The following snippet is just a sample of what can be done:
Thanks. I do not need the data into the form at this time. I have read the sample, the docs and some json articles. I can reproduce the sample in my application. However, when I try to improve, so it can load the entire file to the tree, I have no sucess. Sorry but its being dificult to understand how to define the ‘child’ levels specifically to my json file. Could you please expand the sample so it can load the entire “city” element ? Than I will study it and try to do the “list” element myself? Thanks in advance for your patience.
I’m afraid the ui.tree won’t handle the data item with such structure. The tree requires the same key for a level, so the partial representation (as provided above) is possible, but in another case, you need to modify the data before parsing it to the component.
Ok no problem, I will keep loading and parse by using regular jscript and populate data of webix components using setValue, or other methods. Thanks.