If the Master is Server bound, can the children be ajax? I have view pages that are rendered by the model. If a user wants to drill into the data, I want to make an ajax call. Is that possible?
Right now when I try it with master server bound and child ajax, the Ajax call is never made. With Firebug, I can see no HTTP call is made.
9 Answers, 1 is accepted
This should work. Here is the setup I tested based on our online demo:
<% Html.Telerik().Grid(Model)
.Name(
"Employees"
)
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(140);
columns.Bound(e => e.LastName).Width(140);
columns.Bound(e => e.Title).Width(200);
columns.Bound(e => e.Country).Width(200);
columns.Bound(e => e.City);
})
.DetailView(detailView => detailView.Template(e =>
{
%>
<%= Html.Telerik().Grid<OrderDto>()
.Name(
"Orders_"
+ e.EmployeeID)
.Columns(columns =>
{
columns.Bound(o => o.OrderID).Width(101);
columns.Bound(o => o.ShipAddress).Width(200);
})
.Pageable()
.Sortable()
.Filterable()
.DataBinding(dataBinding => dataBinding.Ajax().Select(
"_OrdersForEmployeeHierarchyAjax"
,
"Grid"
,
new
{ employeeID = e.EmployeeID }))
%>
<%
}))
.Pageable(paging => paging.PageSize(5))
.Sortable()
.Render();
%>
Atanas Korchev
the Telerik team
Thanks. Turns out I was passing the wrong class to the Html.Telerik().Grid generic and an exception was being thrown.
In my code I am trying to bind the Master Grid with Server Binding. Based on the data I need to populate respective details in the Child Grid using Lazy loading.
I am currently stuck as the Detail View needs to be Dynamic in nature, how can we transform the below example so the Detail View binds to the DataTable or any GenericType using Ajax?
TIA
I am not sure what you are after. Could you please clarify what you need? The example shown below will create a master grid whose detail will be ajax bound. How is your requirement different?
Greetings,Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
.DetailView(detailView => detailView.Template(e =>
{
%>
<%= Html.Telerik().Grid<OrderDto>()
2. It would be of great help if you could please share the Model and Controller in the below example. or provide the solution as attachment.
Please let know if these are enough details or provide me with your email id where I can contact Telerik Support.
The model used in my sample (OrderDto) is reused across our online examples.
I am afraid we don't support binding to DataTable in this case as the grid cannot generate automatically the columns on the client-side. The columns need to be defined server side. You can still use ajax binding if the columns are predefined. Please check this code library project which shows how to bind the grid to DataTable.
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
I'm trying to do the same kind of master detail relationship where master data is server bound and detail data is ajax bound and loads only upon request. (i.e when master row is expanded). In the initial server binding request only the master data is populated while detailed data is not. The master grid renders fine.
However upon expansion no ajax request is initiated thus no detailed grid.
Here's the view; (What am I doing wrong here?)
Html.Telerik().Grid(Model.Summaries)
.Name("GridSummary")
.DataKeys(keys => keys.Add(k=> k.UniqueId))
.Columns(columns =>
{
columns.Bound(c => c.Description);
columns.Bound(c => c.MonthlyTotal);
})
.DetailView(detailView => detailView.Template(e =>
{
Html.Telerik().Grid<MovementDto>()
.Name("Movements_" + e.UniqueId)
.Columns(columns =>
{
columns.Bound(m => m.StartTime);
columns.Bound(m => m.MonthlyTotal);
})
.DataBinding(databinding => databinding.Ajax().Select("_LoadMovementsForDetailLevel", "Grid", new {uniqueId = e.UniqueId}));
}
)
).Render();
Object Model is;
- Model.Summaries ==> List<SummaryDto>
- SummaryDto : MovementDto = 1 : n
I think the problem was more view engine related, since this is razor not web forms as pr the previous examples.
I got it to work by enclosing the child grid in @<text> tags. This forced Razor to render the child grid on the server.
@<text>
@{
Html.Telerik().Grid<MovementDto>()
.Name("Movements_" + e.UniqueId)
.Columns(columns =>
{
columns.Bound(m => m.StartTime);
columns.Bound(m => m.MonthlyTotal);
})
.DataBinding(databinding => databinding.Ajax().Select("_LoadMovementsForDetailLevel", "Grid", new {uniqueId = e.UniqueId}))
.Render();
}
</text>
)
while ajax binding this (GridBindingToDataTable) project attached is giving error. which i am not able to find, can u please help.
error: the url is not returning json
Regards,
Rahul Dedhia.