Hello, syncfusion Teams.
No matter how much I check the Manual or Demo, I can't find how to do what I want.
i really want to use TreeGrid. Please give solution.
As I used in datagrid, I want to connect Datamanage to DB rather than webapi method to get data and use crud.
We are testing by adding to the sample provided by syncfusion.
I underlined the desired changes in the Sample. Please check this case.
The tree Datasource must be fetched from the DB, and additions or modifications must be reflected.
In addition, please suggest whether there is a way to designate Parent when adding.
ADD CONTENTS
- Is it possible to set the ComboBox Data in the back column to change according to the ComboBox Data in the front column is selected in the ADD / EDIT situation?
<SampleCode - cshtml>
<ejs-treegrid id="EqSelTree" loadChildOnDemand="true" idMapping="TaskID" parentIdMapping="ParentItem" hasChildMapping="isParent" treeColumnIndex="1" gridLines="Both" rowHeight="30" toolbar="@(new List<string>() { "Add","Delete","Update","Cancel" })">
<e-data-manager url="/HvacInform/HD_EQSEL_URL" crudUrl="/HvacInform/HD_EQSEL_CRUD" adaptor="WebApiAdaptor" crossDomain="true"></e-data-manager>
<e-treegrid-editsettings allowAdding="true" allowEditing="true" allowDeleting="true" mode="Batch" newRowPosition="Bottom"></e-treegrid-editsettings>
<e-treegrid-columns>
<e-treegrid-column field="TaskId" headerText="Task ID" isPrimaryKey="true" textAlign="Right" width="90"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="180"></e-treegrid-column>
<e-treegrid-column field="StartDate" headerText=" Start Date" textAlign="Right"
format="yMd" type="date" width="90"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="80"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
Thanks for the reply.
Somehow, I activated TreeGrid. But, unlike the example sample, the data came out weird. Why?
I want to get db data, so i must be use UrlAdaptor.
Please give me a solution
<Sample Code>
<ejs-treegrid id="TreeGrid" idMapping="TaskID" height="260" parentIdMapping="ParentItem" hasChildMapping="isParent" treeColumnIndex="1">
<e-data-manager url="https://ej2services.syncfusion.com/production/web-services/api/SelfReferenceData" adaptor="WebApiAdaptor" crossDomain="true"></e-data-manager>
<e-treegrid-columns>
<e-treegrid-column field="TaskID" headerText="Task ID" textAlign="Right" width="90"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="180"></e-treegrid-column>
<e-treegrid-column field="StartDate" headerText=" Start Date" textAlign="Right"
format="yMd" type="date" width="90"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="80"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
<MyCode>
<ejs-treegrid id="EqSelTree" idMapping="TaskId" hasChildMapping="isParent" parentIdMapping="ParentItem" treeColumnIndex="0"
created="eqSelCreated" gridLines="Both" rowHeight="30" toolbar="@(new List<string>() { "Add","Delete","Update","Cancel" })">
<e-treegrid-editsettings allowAdding="true" allowEditing="true" allowDeleting="true" mode="Batch" newRowPosition="Bottom"></e-treegrid-editsettings>
<e-treegrid-columns>
<e-treegrid-column field="TaskId" isPrimaryKey="true" headerText="Task ID" textAlign="Right" width="90"></e-treegrid-column>
<e-treegrid-column field="TaskName" headerText="Task Name" width="180"></e-treegrid-column>
<e-treegrid-column field="StartDate" headerText=" Start Date" textAlign="Right" format="yMd" type="date" width="90"></e-treegrid-column>
<e-treegrid-column field="Duration" headerText="Duration" textAlign="Right" width="80"></e-treegrid-column>
<e-treegrid-column field="ParentItem" headerText="ParentItem" textAlign="Right" width="80"></e-treegrid-column>
<e-treegrid-column field="isParent" headerText="isParent" textAlign="Right" width="80"></e-treegrid-column>
</e-treegrid-columns>
</ejs-treegrid>
function eqSelCreated() {
var DataGrid = document.getElementById("EqSelTree").ej2_instances[0];
DataGrid.dataSource = new ej.data.DataManager({
url: "/HvacInform/HD_EQSEL_URL",
insertUrl: "/HvacInform/HD_EQSEL_INSERTURL",
updateUrl: "/HvacInform/HD_EQSEL_UPDATEURL",
removeUrl: "/HvacInform/HD_EQSEL_REMOVEURL",
adaptor: new ej.data.UrlAdaptor()
});
}
public class TreeGridItems
{
public TreeGridItems() { }
public bool isParent { get; set; }
public int TaskId { get; set; }
public string TaskName { get; set; }
public DateTime StartDate { get; set; }
public int Duration { get; set; }
public int? ParentItem { get; set; }
public static List<TreeGridItems> GetSelfData()
{
List<TreeGridItems> BusinessObjectCollection = new List<TreeGridItems>();
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 1,
TaskName = "Parent Task 1",
StartDate = new DateTime(2017, 10, 23),
Duration = 10,
ParentItem = null,
isParent = true
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 2,
TaskName = "Child task 1",
StartDate = new DateTime(2017, 10, 23),
Duration = 4,
ParentItem = 1,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 3,
TaskName = "Child Task 2",
StartDate = new DateTime(2017, 10, 24),
Duration = 5,
ParentItem = 1,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 4,
TaskName = "Child task 3",
StartDate = new DateTime(2017, 10, 25),
Duration = 6,
ParentItem = 1,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 5,
TaskName = "Parent Task 2",
StartDate = new DateTime(2017, 10, 23),
Duration = 10,
ParentItem = null,
isParent = true
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 6,
TaskName = "Child task 1",
StartDate = new DateTime(2017, 10, 23),
Duration = 4,
ParentItem = 5,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 7,
TaskName = "Child Task 2",
StartDate = new DateTime(2017, 10, 24),
Duration = 5,
ParentItem = 5,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 8,
TaskName = "Child task 3",
StartDate = new DateTime(2017, 10, 25),
Duration = 6,
ParentItem = 5,
isParent = false
});
BusinessObjectCollection.Add(new TreeGridItems()
{
TaskId = 9,
TaskName = "Child task 4",
StartDate = new DateTime(2017, 10, 25),
Duration = 6,
ParentItem = 5,
isParent = false
});
return BusinessObjectCollection;
}
}
public ActionResult HD_EQSEL_URL([FromBody] DataManagerRequest dm)
{
List<TreeGridItems> BusinessObjectCollection = TreeGridItems.GetSelfData();
int i = BusinessObjectCollection.Count;
return dm.RequiresCounts ? Json(new { result = BusinessObjectCollection, count = i }) : Json(BusinessObjectCollection);
}
Hello, Farveen Sulthana Thameeztheen Basha.
Thank you for your full service.
<ejs-treegrid id="EqSelTree" allowTextWrap="true" height="670" cellEdit="treeCellEdit" idMapping="EQ_NO" hasChildMapping="IS_PARENT" parentIdMapping='P_EQ_NO' treeColumnIndex="0" toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })">
<e-data-manager url="/HvacInform/[email protected]&[email protected]&[email protected]" crudUrl="/HvacInform/[email protected]&[email protected]&[email protected]" adaptor="UrlAdapto
r"></e-data-manager>
but, There is problem with using the "created" event.Hi, Farveen Sulthana Thameeztheen Basha
i tried to your code. but, i couldn't get what i want.
Please check the attached file again.
(i send controller & view folders)
thank you