- Home
- Forum
- ASP.NET MVC
- Treegrid - Child rows from a FK table
Treegrid - Child rows from a FK table
I have two tables, Customer & Orders (orders has FK to Customer ID Table)
- How can I show Customers records from Customer Table in 1st level.
- How can I show all Orders records as 2nd level under each Customer Records
- How to enable this as CRUD DB, so any changes at each record is save in the correct table, can you give me a sample of this working. I.e. Customer Rec edit to Customer table, Orders Rec to Orders table
- How to enable drag and drop in the child rows only, so when user moves/drags the records to a diff parent rec and saves. The Customer Id is also updated in the orders table.
Thanks
Hello, thanks for the answer. I am trying to use the
1) Drag and drop feature from one parent to another parent records. (but not move parents & not make child record parents), does the SF grid support this need?
2) CRUD Edit records both parent and child records feature in the Tree Grid & perform CRUD. Are you saying I can achieve this AJAX CRUD for both parent & child records in the hierarchy grid? the sample does not show this. Can you please share a working sample with me for the CRUD & drag+drop as mentioned in the above.
I am not following "s but all the data sources column names should be same" why would someone have 2 table with identical columns & names, it makes no sense... can you please elaborate with a small example. Are you saying some col names should be the same or the full structure should be the same?
Thanks
|
<div style="float:left;width:50%">
@(Html.EJ().Grid<object>("FlatGrid")
---
.AllowRowDragAndDrop()
.RowDropSettings(drop => drop.DropTargetID("#HierarchyGrid"))
----
.Columns(col =>
{
---
})
.ChildGrid(child =>
{
----
})
)
</div>
<div style="float:right;width:49%">
@(Html.EJ().Grid<object>("HierarchyGrid")
----
.AllowRowDragAndDrop()
.RowDropSettings(drop => drop.DropTargetID("#FlatGrid"))
.Columns(col =>
{
---
})
.ChildGrid(child =>
{
----
})
)
</div>
|
|
<div style="float:left;width:50%">
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource).UpdateURL("/Grid/Update")
.InsertURL("/Grid/Insert").RemoveURL("/Grid/Remove").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(tool =>
{
tool.ShowToolbar().ToolbarItems(toolitem =>
{
toolitem.AddTool(ToolBarItems.Add);
----
});
})
.Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).ValidationRules(v => v.AddRule("required", true)).Width(75).Add();
---
})
.ChildGrid(child =>
{
child.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.childDatasource)
.UpdateURL("/Grid/Update3").InsertURL("/Grid/Insert3").RemoveURL("/Grid/Remove3")
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.QueryString("EmployeeID")
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(tool =>
{
tool.ShowToolbar().ToolbarItems(toolitem =>
{
toolitem.AddTool(ToolBarItems.Add);
----
});
})
.Columns(col =>
{
col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
-----
});
})
)
</div>
<div style="float:right;width:49%">
@(Html.EJ().Grid<object>("HierarchyGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource2).UpdateURL("/Grid/Update2")
.InsertURL("/Grid/Insert2").RemoveURL("/Grid/Remove2").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(tool =>
{
tool.ShowToolbar().ToolbarItems(toolitem =>
{
toolitem.AddTool(ToolBarItems.Add);
----
});
})
.Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).ValidationRules(v => v.AddRule("required", true)).Width(75).Add();
-----
})
.ChildGrid(child =>
{
child.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.childDatasource2)
.UpdateURL("/Grid/Update3").InsertURL("/Grid/Insert3").RemoveURL("/Grid/Remove3")
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.QueryString("EmployeeID")
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(tool =>
{
tool.ShowToolbar().ToolbarItems(toolitem =>
{
toolitem.AddTool(ToolBarItems.Add);
----
});
})
.Columns(col =>
{
col.Field("OrderID").HeaderText("OrderID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
----
});
})
)
</div>
|
- 3 Replies
- 3 Participants
-
ME Megatron
- Aug 22, 2017 04:52 PM UTC
- Aug 24, 2017 02:13 PM UTC