We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Treeview with PHP

Thread ID:

Created:

Updated:

Platform:

Replies:

126224 Oct 2,2016 09:30 PM UTC Oct 10,2016 11:52 AM UTC JavaScript 3
loading
Tags: ejTreeView
Ahmed Lazreg
Asked On October 2, 2016 09:30 PM UTC

Hello,
I'm using Treeview with a PHP application. I was filling the datasource using local data generated via PHP. I want to know how can I use a php ajax call to serve as datasource?
There is no documentation about that. Must I create an oData compatible source? or is it possible to have a simple php script generating JSON data to build the tree?
Any example is very appreciated.
Thank you

Regards

Piramanayagam Ramakrishnan [Syncfusion]
Replied On October 3, 2016 12:49 PM UTC

Hi Ahmed, 
 
Thanks for contacting Syncfusion support. 
 
We have analyzed your query. We would like to inform you that, TreeView is compatible with local data source and OData service.  
 
For local data-source binding: 
We can decode the JSON data using json_decode method and assign to TreeView control. Please refer the below code example, 
 
[PHP] 
 
<?php 
$Json = json_decode(file_get_contents("Data.json"), true); 
$treeview = new \EJ\TreeView("localData"); 
$fields = new EJ\TreeView\Field(); 
$fields->id("id")->text("name")->parentId("pid")->hasChild("hasChild")->dataSource($Json)->expanded("expanded")->isChecked("isChecked"); 
echo $treeview->fields($fields)->render(); 
?> 
 
 
For your reference, we have prepared the TreeView sample with JSON data in the below link: Sample 
 
OData Service: 
We can also provide the OData service to TreeView control, please refer the below code example, 
 
[PHP] 
 
<?php 
$dataManager = new \EJ\DataManager(); 
$dataManager->url("//mvc.syncfusion.com/Services/Northwnd.svc/"); 
 
$query = new \EJ\Query(); 
$query->from("Categories")->select("CategoryID,CategoryName")->take(3); 
 
$child = new \EJ\TreeView\Field(); 
$child->dataSource($dataManager)->tableName("Products")->parentId("CategoryID")->text("ProductName"); 
 
$treeview = new \EJ\TreeView("remoteData"); 
$fields = new EJ\TreeView\Field(); 
$fields->id("CategoryID")->text("CategoryName")->dataSource($dataManager)->query($query)->child($child); 
 
echo $treeview->height("300px")->width("300px")->fields($fields)->render(); 
?> 
 
 
We have live demo sample for your requirement (TreeView with OData service). Please refer the below link: http://php.syncfusion.com/#Navigation/TreeView/remoteData.php 
 
Currently we are preparing the document for PHP platform. We will publish the document on or before 31th October 2016. 
 
Please let us know whether the provided sample is helpful in achieving your requirement. If not, get back to us with more information for us to assist you. 
 
Regards, 
Piramanayagam R

Ahmed Lazreg
Replied On October 7, 2016 04:36 PM UTC

Hello,
thank you for your answer. But in your php example, you are using some set of classes that I cannot found in syncfusion source codes (EJ\Datatamanager for example). Where can we find this librarie of php classes?

Regards

Balamurugan P [Syncfusion]
Replied On October 10, 2016 11:52 AM UTC

Hi Ahmed, 
You can access the Syncfusion related PHP libraries from  Essential Studio package installed location that is available in your system.  
 
(installed location)\Syncfusion\Essential Studio\14.3.0.49\Samples\PHP => SampleBrowser\EJ 
 
For example, If you have installed the Essential Studio package within C:\Program Files(x86), then navigate to the below location, C:\Program Files (x86)\Syncfusion\Essential Studio\14.3.0.49\Samples\PHP => SampleBrowser\EJ 
 
Please let us know if you require any further assistance. 

Regards, 
Balamurugan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;