BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Person{
string Name;string Surname;List<Purchase> Purchases;
}Purchase{
string Description;int Amount;List<Item> Items;
}Item{
string Code;int Cost;
}
@(Html.EJ().Grid<object>("Grid") //Main grid - Binds `Person` .Datasource((IEnumerable<object>)ViewBag.griddata) .Columns(col => {
col.Field("Name").HeaderText("Name").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("SurName").HeaderText("SurName").Width(80).Add();
}) //Level one grid - Binds List<Purchase> .ChildGrid(child1 => { child1.QueryString("") .Columns(col => {
col.Field("Description").HeaderText("Description").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Amount").HeaderText("Amount").Width(80).Add();
}) //Level two grid - Binds List<Item> .ChildGrid(child2 => child2.QueryString("") .Columns(col => {
col.Field("Code").HeaderText("Code").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Cost").HeaderText("Cost").Width(80).Add();
}) ) .ClientSideEvents(evt => evt.DetailsExpand("OnChild2Expand")); } ) |
/* DetailsExpand event will be trigged before child grid rendered * The current Purchase list will be assigned as datasource to the child grid.*/ function OnChild1Expand(args) { this.model.childGrid.query = new ej.Query(); this.model.childGrid.dataSource = args.masterData["Purchases"]; }
function OnChild2Expand(args) { this.model.childGrid.query = new ej.Query(); this.model.childGrid.dataSource = args.masterData["Item"]; |
Person{
int id;string Name;string Surname;List<Purchase> Purchases;List<Address> Addresses;
}Purchase{
int id;string Description;int Amount;
}Address{int id;string City;string PostalCode;}Now, this needs to be mapped to a 2-level Hierarchical datagrid, where each parent row should contain 2 child grids (instead of 1): one for "Purchases" and one for "Addresses". This way, by expanding a "Person" row, I should be able to see 2 child grids, one with the person Purchases and the other for the person Addresses. Is it possible to achieve such a requirement with syncfusion mvc grid (I'm using the last version as of now). Thanks a lot for your kind help, as always.
(Html.EJ().Grid<object>("DetailTemplate")
.Datasource((IEnumerable<object>)ViewBag.datasource)
. . . .
. . . .
.DetailsTemplate("#tabGridContents")
.ClientSideEvents(eve => { eve.DetailsDataBound("detailGridData"); })
)
<script id="tabGridContents" type="text/x-jsrender">
<div class="tabcontrol" id="Test">
<ul>
<li><a rel='nofollow' href="#gridTab1{{:Id}}">Grid1</a></li>
<li><a rel='nofollow' href="#gridTab{{:Id}}">Stock Grid</a></li>
</ul>
<div id="gridTab1{{:Id}}">
<div id="detailGrid1">
</div>
</div>
<div id="gridTab{{:Id}}">
<div id="detailGrid">
</div>
</div>
</div>
</script>
<script type="text/javascript">
function detailGridData(e) {
var filteredData = e.data["Id"];
var data = ej.DataManager(e.data.Purchases).executeLocal(ej.Query().where("EmployeeID", "equal", parseInt(filteredData), true));
e.detailsElement.find("#detailGrid").ejGrid({
dataSource: data,
allowSelection: false,
allowPaging:true,
. . . .
. . . .
});
e.detailsElement.css("display", "");
var data1 = ej.DataManager(e.data.Addresses).executeLocal(ej.Query().where("Id", "equal", parseInt(filteredData), true));
e.detailsElement.find("#detailGrid1").ejGrid({
dataSource: data1,
. . . .
. . . .
});
e.detailsElement.find(".tabcontrol").ejTab({ selectedItemIndex: 0 });
}
</script> |