0
votes

I have Telerik MVC hierarchy grid. I need to conditionally make child grid for the master grid. I have tried many options but didn't work anything. Can i provide If condition for the child grid. Please provide a way that i can use it.

View Code

      .DetailView(details => details.ClientTemplate("<# if (CustomerID > 0) { #>" // I tried like this. but showing **) expected **
      Html.Telerik().Grid<Vibrant.Areas.Acquisition.Models.PoDetails>()
                                .Name("Details<#=Id#>").DataKeys(keys => keys.Add(c => c.Id)).ClientEvents(cli => cli.OnDelete("DeletePoDetails").OnLoad("SetFilterPosition").OnRowDataBound("onRowData"))
                                .Columns(columns =>
                                {
                                    columns.Bound(o => o.SNo).Width(27).Title("S.No").ClientTemplate(Html.ActionLink("<#=SNo#>", "Edit_PoDetails", "Porders", new { Id = "<#=Id#>" }, null).ToHtmlString().Replace("id", "\\#=Id\\#")); ;
                                    columns.Bound(o => o.Title).Width(110);
                                    columns.Bound(o => o.UnitPrice).Width(45).Title("Unit Price");
                                    columns.Bound(o => o.Copies).Width(30);
                                    columns.Bound(o => o.Account).Width(40);
                                    columns.Bound(o => o.Status).Width(40);

                                    columns.Command(commands =>
                                    {
                                        commands.Delete();
                                    }).Width(60).Title("Action");
                                })
                                .DataBinding(dataBinding => dataBinding.Ajax()
                                    .Select("HierarchyBinding_PoDetails", "Porders", new { Id = "<#= Id #>" }).Delete("Hierarchy_Delete", "PoDetails", new { Id = "<#=Id#>" }))
                                .Pageable()
                                .Sortable()
                                .Filterable()
                                .Groupable()
                                .ToHtmlString()
                               "<# } #> " ))
1

1 Answers

0
votes

Actually you are pretty close to success I tried the following and it is working fine on my side. Still not sure where the difference is.

.DetailView(dv => dv.ClientTemplate("<# if(PersonID%2==0) { #>" + Html.Telerik().DatePicker().Name("dp<#=PersonID#>").ToHtmlString() + "<# }#>"))