DataManager and JSON File
Hello!
I would like to use Datamanager with treeGrid.
Scenario 1 - JSON file on the server
I have a JSON file on the server.
I would like to use DataManager to get the JSON file and deliver to the datasource attribute of the ejTreeGrid control.
How does one do that most simply using DataManager?
Scenario 2 - JSON file on the server and a PHP file that will echo a JSON file
I have a JSON file on the server and a simple PHP file that will echo the JSON file when called.
I would like to use DataManager to get the JSON file and deliver to the datasource attribute of the ejTreeGrid control.
How does one do that most simply using DataManager?
Thanks,
Derrick
SIGN IN To post a reply.
3 Replies
JD
Jayakumar Duraisamy
Syncfusion Team
January 26, 2018 11:10 AM UTC
Hi Derrick,
Please find the response below.
Query 1: I would like to use DataManager to get the JSON file and deliver to the datasource attribute of the ejTreeGrid control.How does one do that most simply using DataManager?
Answer: We can directly get the data from the JSON file by pass the server address to the ej.DataManager().
Please refer following code snippet,
|
$(function () {
var data = ej.DataManager({
});
$("#treegrid").ejTreeGrid({
dataSource: data,
});
}); |
Please refer following link to know more about TreeGrid remote data binding,
Query 2: I have a JSON file on the server and a simple PHP file that will echo the JSON file when called.
Answer: In PHP, we have a method file_get_contents(), by using this method, we can read data from the JSON file and decode the data to JSON format.
Please refer following code snippet,
|
// Read data from the JSON file
$jsonData = file_get_contents(“http://Syncfusion.com/***/**/treeGridData.json”);
// Decode the data as JSON data
$treeGridData = json_decode($jsonData, true);
function getData(){
echo json_encode($treeGridData);
} |
|
$(function () {
var data = ej.DataManager({
});
$("#treegrid").ejTreeGrid({
dataSource: data,
});
}); |
Please refer the following KB to know more about CRUD operation with MySQL database in PHP platform.
Please let us know, if you need any other assistance.
Regards,
Jayakumar D
DE
Dee
January 26, 2018 06:56 PM UTC
Thanks, Jayakumar.
So, just pass in the name of the file or source. Kool.
And thanks for the code samples.
Cheers.
JD
Jayakumar Duraisamy
Syncfusion Team
January 29, 2018 04:58 AM UTC
Hi Derrick,
Thanks for the update.
Regards,
Jayakumar D
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
DE Dee
- Jan 25, 2018 02:06 PM UTC
- Jan 29, 2018 04:58 AM UTC