This is my previous grid example where it has one child grid. so i want to add 2nd child gird same like first one with all the features same.
@(Html.EJ().Grid("ProductRange")
.Datasource(datasource => datasource.Json((IEnumerable
)Model)
.UpdateURL(@Url.Action("UpdateProductRange")).InsertURL(@Url.Action("CreateProductRange"))
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowEditing().AllowEditOnDblClick(false).EditMode(EditMode.InlineForm).ShowConfirmDialog(true).TitleColumn("Name"); })
.ToolbarSettings(toolbar =>
{
if (CurrentUser.HasFullPageControl(Permission.Products))
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
});
}
})
.AllowFiltering()
.AllowSorting()
.AllowPaging()
.AllowResizing()
.EnableHeaderHover()
.EnableRowHover()
.AllowSelection()
.PageSettings(builder => builder.PageSizeList(new List
{ 50, 200, 500, 10000 }))
.PageSettings(p => p.PageSize(50))
.FilterSettings(filter => { filter.MaxFilterChoices(int.MaxValue); filter.FilterType(FilterType.Excel); })
.Locale("en-GB")
.Columns(col =>
{
col.Field(x => x.Id)
.HeaderText("Id").Visible(false)
.TextAlign(TextAlign.Left)
.Add();
col.Field(x => x.Name)
.TextAlign(TextAlign.Left)
.Add();
col.HeaderText("Actions")
.Template(CurrentUser.HasFullPageControl(Permission.Products) ? "{{if Name !='Specials'}}
Edit{{/if}}"
: "")
.TextAlign(TextAlign.Center)
.Width(70).
Add();
})
.ClientSideEvents(events =>
{
events.ActionFailure("mrp.productRanges.productRangeActionFailure");
events.ActionComplete("mrp.productRanges.productRangeActionComplete");
})
.ChildGrid
(child =>
{
child.Datasource(datasource => datasource.URL(@Url.Action("GetAllProductCodeCombinationsRangeId"))
.UpdateURL(@Url.Action("UpdateProductCodeCombination"))
.InsertURL(@Url.Action("CreateProductCodeCombination")).RemoveURL(@Url.Action("RemoveProductCodeCombination"))
.Adaptor(AdaptorType.UrlAdaptor))
.QueryString("Id").EditSettings(edit => { edit.AllowAdding().AllowEditing().AllowDeleting().AllowEditOnDblClick(false)
.EditMode(EditMode.InlineFormTemplate).InlineFormTemplateID("#productCodeCombinations").ShowConfirmDialog(true).TitleColumn("Content"); })
.ToolbarSettings(toolbar =>
{
if (CurrentUser.HasFullPageControl(Permission.Products))
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
});
}
})
.CssClass("childGridBackgroundColor childGrid60PercentWidth")
.AllowPaging(false)
.Locale("en-GB")
.Columns(col =>
{
col.Field(x => x.Id).Visible(false)
.TextAlign(TextAlign.Left)
.Add();
col.Field(x => x.RangeId).Visible(false)
.TextAlign(TextAlign.Left)
.Add();
col.Field(x => x.ProductCount)
.AllowSorting(false)
.AllowFiltering(false).AllowEditing(true)
.Width(80)
.TextAlign(TextAlign.Center)
.Add();
col.Field(x => x.Content)
.TextAlign(TextAlign.Left).DefaultValue("[ProductCode]")
.Add();
col.HeaderText("Actions")
.Template(CurrentUser.HasFullPageControl(Permission.Products) ? "
Edit" +
.TextAlign(TextAlign.Center)
.Width(100).
Add();
}).ClientSideEvents(events =>
{
events.ActionComplete("mrp.productRanges.productCodeCombinationActionComplete");
events.ActionFailure("mrp.productRanges.productRangeActionFailure");
events.RowDataBound("mrp.productRanges.productCodeCombinationRowDataBound");
});
})
)
I have tried to convert my HTML to like this. as shown in example
@(Html.EJ().Grid("ProductRange")
.Datasource(datasource => datasource.Json((IEnumerable
)Model)
.UpdateURL(@Url.Action("UpdateProductRange")).InsertURL(@Url.Action("CreateProductRange"))
.Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit => { edit.AllowAdding().AllowEditing().AllowEditOnDblClick(false).EditMode(EditMode.InlineForm).ShowConfirmDialog(true).TitleColumn("Name"); })
.ToolbarSettings(toolbar =>
{
if (CurrentUser.HasFullPageControl(Permission.Products))
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
});
}
})
.AllowFiltering()
.AllowSorting()
.AllowPaging()
.AllowResizing()
.EnableHeaderHover()
.EnableRowHover()
.AllowSelection()
.PageSettings(builder => builder.PageSizeList(new List
{ 50, 200, 500, 10000 }))
.PageSettings(p => p.PageSize(50))
.FilterSettings(filter => { filter.MaxFilterChoices(int.MaxValue); filter.FilterType(FilterType.Excel); })
.DetailsTemplate("#tabGridContents")
.Locale("en-GB")
.Columns(col =>
{
col.Field(x => x.Id)
.HeaderText("Id").Visible(false)
.TextAlign(TextAlign.Left)
.Add();
col.Field(x => x.Name)
.TextAlign(TextAlign.Left)
.Add();
col.HeaderText("Actions")
.Template(CurrentUser.HasFullPageControl(Permission.Products) ? "{{if Name !='Specials'}}
Edit{{/if}}"
: "")
.TextAlign(TextAlign.Center)
.Width(70).
Add();
})
.ClientSideEvents(events =>
{
events.ActionFailure("mrp.productRanges.productRangeActionFailure");
events.ActionComplete("mrp.productRanges.productRangeActionComplete");
events.DetailsDataBound("mrp.productRanges.productRangeDetailsDataBound");
})
)
And my Javascript is:
function productRangeDetailsDataBound(args) {
args.detailsElement.find("#detailGrid").ejGrid({
dataSource: ej.DataManager({ url: "/ProductRanges/GetAllProductCodeCombinationsRangeId", updateUrl: "/ProductRanges/UpdateProductCodeCombination", insertUrl: "/ProductRanges/CreateProductCodeCombination", removeUrl: "/Home/RemoveProductCodeCombination", adaptor: "UrlAdaptor" }),
queryString: "Id",
allowPaging: false,
cssClass: "childGridBackgroundColor childGrid60PercentWidth",
editSettings: { allowAdding: true, allowDeleting: true, allowEditing: true, AllowEditOnDblClick: false, editMode: "InlineFormTemplate", inlineFormTemplateID: "#productCodeCombinations",showConfirmDialog:true,titleColumn:"Content" },
toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add] },
allowFiltering: false,
allowSorting: false,
actionComplete: "mrp.productRanges.productCodeCombinationActionComplete",
actionFailure: "mrp.productRanges.productRangeActionFailure",
rowDataBound: "mrp.productRanges.productCodeCombinationRowDataBound",
columns: [
{ field: "Id", isPrimaryKey: true, visible: false, textAlign: ej.TextAlign.Right },
{ field: "RangeId", visible: false },
{ field: "ProductCount", headerText: "Products", width: 80, textAlign: ej.TextAlign.Center, template: "[{{:ProductCount}}]" }, { field: "Content", headerText: "Content", validationRules: { required: true }, textAlign: ej.TextAlign.Left, defaultValue: "[ProductCode]" },
{ headerText: 'Actions', template: "Edit  Delete", textAlign: ej.TextAlign.Center, width: 100 } ]
}).ejGrid("instance");
args.detailsElement.find("#seconddetailGrid").ejGrid({
dataSource: ej.DataManager({ url: "/ProductRanges/GetAllProductCodeCombinationsRangeId", updateUrl: "/ProductRanges/UpdateProductCodeCombination", insertUrl: "/ProductRanges/CreateProductCodeCombination", removeUrl: "/Home/RemoveProductCodeCombination", adaptor: "UrlAdaptor" }),
queryString: "Id",
allowPaging: false,
cssClass: "childGridBackgroundColor childGrid60PercentWidth",
editSettings: { allowAdding: true, allowDeleting: true, allowEditing: true, AllowEditOnDblClick: false, editMode: "InlineFormTemplate", inlineFormTemplateID: "#productCodeCombinations", showConfirmDialog: true, titleColumn: "Content" },
toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add] },
allowFiltering: false,
allowSorting: false,
actionComplete: "mrp.productRanges.productCodeCombinationActionComplete",
actionFailure: "mrp.productRanges.productRangeActionFailure",
rowDataBound: "mrp.productRanges.productCodeCombinationRowDataBound",
columns: [
{ field: "Id", isPrimaryKey: true, visible: false, textAlign: ej.TextAlign.Right },
{ field: "RangeId", visible: false },
{ field: "ProductCount", headerText: "Products", width: 80, textAlign: ej.TextAlign.Center, template: "[{{:ProductCount}}]" }, { field: "Content", headerText: "Content", validationRules: { required: true }, textAlign: ej.TextAlign.Right, defaultValue: "[ProductCode]" },
{ headerText: 'Actions', template: "Edit  Delete", textAlign: ej.TextAlign.Center, width: 100 } ]
}).ejGrid("instance");
}
I am facing 1 main issue here.
1 st: on the server side method I am not getting the Id of parent grid while calling GetAllProductCodeCombinationsRangeId which I was used to get earlier. how to pass the Id in where query in server side same like parent child grid.
I believe I am doing something wrong in javascript but not quite figured out what is wrong.