[C#]
public static List<Data> GetData() {
List<Data> obj = new List<Data>();
obj.Add(new Data() { OrderID = 1000, EmployeeID = 1, ShipCountry = "india", Employee = new List<ChildData>() { new ChildData() { EmployeeID = 1, FirstNAme = "Janet", LastNAme = "David" }}});
obj.Add(new Data() { OrderID = 1001, EmployeeID = 2, ShipCountry = "France", Employee = new List<ChildData>() { new ChildData() { EmployeeID = 2,FirstNAme = "Nancy", LastNAme = "John" }}});
obj.Add(new Data() { OrderID = 1002, EmployeeID = 3, ShipCountry = "US", Employee = new List<ChildData>() { new ChildData() { EmployeeID = 3, FirstNAme = "David", LastNAme = "Staven" }}});
obj.Add(new Data() { OrderID = 1003, EmployeeID = 4, ShipCountry = "US", Employee = new List<ChildData>() { new ChildData() { EmployeeID = 4, FirstNAme = "Janet", LastNAme = "David" }}});
return obj;
}
|
@(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))
.AllowPaging()
…
.Columns(col =>
{
col.Field("OrderID").IsPrimaryKey(true).AllowEditing(true).Add();
col.Field("EmployeeID").AllowEditing(true).Add();
col.Field("ShipCountry").AllowEditing(true).Add();
})
.ClientSideEvents(eve =>
{
eve.DetailsExpand("detailsexpand");
})
.ChildGrid(child =>
{
child.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.datasource))
.QueryString("EmployeeID")
.AllowPaging()
.ClientSideEvents(e => e.Load("Load"))
.Columns(col =>
{
col.Field("FirstNAme").HeaderText("FirstName").Width(120).Add();
col.Field("LastNAme").HeaderText("LastName").Width(100).Add();
});
})
)
<script type="text/javascript">
var chilGridDta;
function detailsexpand(args) {
chilGridDta = args.masterData.Employee;
}
function Load(args) {
this.model.dataSource = chilGridDta;
}
</script> |