This question is locked. New answers and comments are not allowed.
Thomas Mayfield
Top achievements
Rank 1
Thomas Mayfield
asked on 13 Mar 2012, 10:12 PM
I have an AJAX grid that has nested grids (via ClientTemplate). To load data for the first depth, I need data from the root. For the second depth, I need data from the root and first depth. This is complicated by using the same property name for IDs for parents, children, and grandchildren.
Assuming I have three objects named Root, Child, and SubChild, each with an ID property. To get the Child list is simple, as I can use the <#=ID#> property to filter to those that match Root's ID. To get the SubChild list, I need to use the ID property for both Root and Child, but using <#=ID#> for the client template for the SubChild detail view would only reference the ID property on the Child object. Is there some other way to get access to Root's ID when building the client template for SubChild?
Assuming I have three objects named Root, Child, and SubChild, each with an ID property. To get the Child list is simple, as I can use the <#=ID#> property to filter to those that match Root's ID. To get the SubChild list, I need to use the ID property for both Root and Child, but using <#=ID#> for the client template for the SubChild detail view would only reference the ID property on the Child object. Is there some other way to get access to Root's ID when building the client template for SubChild?
5 Answers, 1 is accepted
0
Dadv
Top achievements
Rank 1
answered on 14 Mar 2012, 10:54 AM
Hi,
The more easy way is to add it to your model i think...
if i had not misunderstood you want something like this (look at this) :
public class Root
{
public int Id {get; set;}
}
public class Child
{
public int Id {get; set;}
public int RootId {get; set;}
}
public class SubChild
{
public int Id {get; set;}
public int RootId {get; set;}
public int ChildId {get; set;}
}
Now it's easy to transfer the Id's to all the grids.
The more easy way is to add it to your model i think...
if i had not misunderstood you want something like this (look at this) :
public class Root
{
public int Id {get; set;}
}
public class Child
{
public int Id {get; set;}
public int RootId {get; set;}
}
public class SubChild
{
public int Id {get; set;}
public int RootId {get; set;}
public int ChildId {get; set;}
}
Now it's easy to transfer the Id's to all the grids.
<%= Html.Telerik().Grid<
EmployeeViewModel
>()
.Name("Root")
.Columns(columns =>
{
columns.Bound(e => e.Id);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectRoots", "Grid"))
.DetailView(details => details.ClientTemplate(
Html.Telerik().Grid<
OrderViewModel
>()
.Name("Child_<#= Id #>")
.Columns(columns =>
{
columns.Bound(o => o.Id);
columns.Bound(o => o.RootId);
})
.DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectChilds", "Grid", new { RootId = "<#= Id #>" }))
.DetailView(
dts =>
dts.ClientTemplate(Html.Telerik().Grid<
OrderViewModel
>()
.DataBinding(dataBinding => dataBinding.Ajax().Select("_SelectSubChilds", "Grid", new { RootId = "<#= RootId #>", ChildId = "<#= Id #>" }))
.Name("SubChild_<#=RootId #>_<#= Id #>")
.Columns(columns =>
{
columns.Bound(o => o.Id);
columns.Bound(o => o.RootId);
columns.Bound(o => o.ChildId);
})
.ToHtmlString()))
.ToHtmlString()))
%>
0
Thomas Mayfield
Top achievements
Rank 1
answered on 14 Mar 2012, 04:46 PM
I explained it with three separate models for simplicity's sake. It's actually the same model three times deep (loading aggregated totals with detailed aggregates below). There's no parent IDs, just filters on GUID columns.
0
Dadv
Top achievements
Rank 1
answered on 14 Mar 2012, 05:14 PM
Could you give a sample project of what you want ?
0
Stella
Top achievements
Rank 1
answered on 19 Apr 2012, 04:55 PM
I am having a similar issue - i have a model that has way too many colums to show in the master grid - so in the detail view i want
to show another grid with the rest of the data - I am also clientside bound.
Can I do this or would i be better off using a different control? thanks.
to show another grid with the rest of the data - I am also clientside bound.
Can I do this or would i be better off using a different control? thanks.
0
Stella
Top achievements
Rank 1
answered on 19 Apr 2012, 05:02 PM
My model has like 12 properties (fields) - i am only showing 4 on the initial grid - in the detail version i want to show the other 8 - but i don't want to have to do another call to the database - I am client side bound -
I tried the scripting
I tried the scripting
function
detailGrid_dataBinding(e) {
var grid = $(this).data("tGrid"),
masterRow = $(
this).closest("tr.t-detail-row").prev(),
dataItem = $(
"#Grid").data("tGrid").dataItem(masterRow);
grid.dataBind(dataItem.CalendarHeadingId);
e.preventDefault();
But it says no data to show - that is the key to the dataitem.