This is a migrated thread and some comments may be shown as answers.
Master Server binding and Child Ajax binding?
9 Answers 89 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jim
Top achievements
Rank 1
jim asked on 23 May 2011, 11:52 PM
From the documentation I see that it says if the master is ajax or web service, the details must be ajax or web service.

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

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 24 May 2011, 07:06 AM
Hi jim,

 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();
%>

All the best,
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
0
jim
Top achievements
Rank 1
answered on 24 May 2011, 04:48 PM
Atanas,

Thanks. Turns out I was passing the wrong class to the Html.Telerik().Grid generic and an exception was being thrown.
0
Sandeep
Top achievements
Rank 1
answered on 28 Jul 2011, 04:07 PM
Atanas,

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
0
Atanas Korchev
Telerik team
answered on 28 Jul 2011, 04:18 PM
Hello Sandeep,

 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

0
Sandeep
Top achievements
Rank 1
answered on 28 Jul 2011, 05:24 PM
1. The requirement is different as I am not sure about the Row Structure of the Detail Grid. I would like to bind the DetailView to a Data Table. In the below example we are binding DetailView with OrderDto whereas in my Case I donot have any specific Type to bind to and best I can go with is a DataTable.

.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.
0
Atanas Korchev
Telerik team
answered on 29 Jul 2011, 09:27 AM
Hello Sandeep,

 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.

All the best,
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

0
Uchitha
Top achievements
Rank 1
answered on 21 Sep 2012, 06:54 AM
Hello Atanas,

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
0
Uchitha
Top achievements
Rank 1
answered on 24 Sep 2012, 02:21 AM
Hi,
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. 

.DetailView(detailView => detailView.Template(
@<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>
                                      ) 
0
RahulD
Top achievements
Rank 1
answered on 19 Oct 2012, 04:29 AM
Hi Atanas,

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.
Tags
Grid
Asked by
jim
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
jim
Top achievements
Rank 1
Sandeep
Top achievements
Rank 1
Uchitha
Top achievements
Rank 1
RahulD
Top achievements
Rank 1
Share this question
or