This is a migrated thread and some comments may be shown as answers.

[Solved] Multple grids on one page with AJAX custom binding

2 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Felipe Casanova
Top achievements
Rank 1
Felipe Casanova asked on 25 Nov 2011, 02:34 PM
I have two grids on one page, using AJAX custom binding. I have action methods as follows:

[Telerik.Web.Mvc.GridAction(EnableCustomBinding = true, GridName = "MailingMergesGrid")]
[Transaction]
public ActionResult MailingMergesForGrid(Telerik.Web.Mvc.GridCommand command)
{
    var rowCount = mailingMergeManagementService.GetMailingMergeSummariesCount(Id);
    IEnumerable<MailingMergeDto> mailingMerges = GetDataForGri(command, mailingMergeManagementService.GetMailingMergeSummaries);
  
    return View(new Telerik.Web.Mvc.GridModel
    {
        Data = mailingMerges,
        Total = rowCount.Value
    });
}

and

[Telerik.Web.Mvc.GridAction(EnableCustomBinding = true, GridName = "MailingList.AdhocContacts")]
[Transaction]
public ActionResult AdHocContactsForGrid(Telerik.Web.Mvc.GridCommand command)
{
 
   var rowCount = mailingMergeManagementService.GetMailingMergeSummariesCount(id);
   IEnumerable<MailingListContactDto> mailingMerges = GetDataForGrid<MailingListContactDto>(command, mailingListContactManagementService.GetAllAddHocMailingContacts);
 
    return View(new Telerik.Web.Mvc.GridModel
    {
        Data = mailingMerges,
        Total = rowCount.Value
    });
}


The first grid works fine. The second grid which uses the second action method AdHocContacts for grid throws an error saying that it can't find the view 

The view 'AdHocContactsForGrid' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/AdHocContactsForGrid.aspx
~/AdHocContactsForGrid.ascx
~/Views/MailingMerges/AdHocContactsForGrid.aspx
~/Views/MailingMerges/AdHocContactsForGrid.ascx
~/Views/Shared/AdHocContactsForGrid.aspx
~/Views/Shared/AdHocContactsForGrid.ascx


Second grid view:

<% Html.Telerik().Grid<MailingListContactDto>()
    .Name("MailingList.AdhocContacts")
    .Columns(columns =>
    {
        columns.Bound(p => p.FullName).HeaderHtmlAttributes(new { @class = "name-column" });
        columns.Bound(p => p.Email).HeaderHtmlAttributes(new { @class = "email-column" });
    })
    .DataBinding(dataBinding => dataBinding.Ajax().Select("AdHocContactsForGrid", "MailingMerges"))
    .Pageable(settings => settings
        .Total((int)ViewData["total"]))
    .EnableCustomBinding(true)
    .Sortable(sorting => sorting
        .OrderBy(sortOrder => sortOrder.Add(p => p.FullName).Ascending()))
    .Render();
%>


Is there something special I need to do to get multiple ajax custom bound grids working ??

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 29 Nov 2011, 08:42 AM
Hi Matt Cowen,

I tried to reproduce the scenario you described but I did not encounter the same behavior. I attached the demo project which uses two Grids with Ajax Custom Binding.

Would you please check if I missed something? If so please modify the project so it covers your scenario and send it back.

Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Felipe Casanova
Top achievements
Rank 1
answered on 29 Nov 2011, 11:33 AM
Thanks for that. Turns out it was the name of the grid: MailingList.AdhocContacts. Basically you can't use a name with a period (.) in it, as the JavaScript generated by the grid replaces it with an underscore (_) :

jQuery('#MailingList_AdhocContacts').tGrid(...)

Might be worth making a note of this in the documentation somewhere? Or is it a bug with the grid?
Tags
Grid
Asked by
Felipe Casanova
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Felipe Casanova
Top achievements
Rank 1
Share this question
or