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

[Solved] Master Detail Ajax Binding not working

3 Answers 160 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.
Jignesh
Top achievements
Rank 1
Jignesh asked on 25 Jul 2011, 08:44 PM
Hi, 

I have simple application to showing Notes and its child notes (memo). I am using MVC grid as Master-Detail.
My problem is that the grid loads fine for the parent rows but on expand of it , it doesn;t call the ajax load method/event for some of the rows. 
The behavior doesn;t have any specific path or not like that it  happen for only specific rows.. it happens for any random parent row. 

I dont have any javacript error also.

My View :
<%
 
     
    var NoteListGrid = Html.Telerik().Grid<Hudson.WebApplications.Navigator.IModels.INote>()
               
                .DataKeys(datakeys => { datakeys.Add(c => c.Note_Id); })
                .Columns(columns =>
                {
                    columns.Bound(e => e.Account_Id).Title("Account#");
                    columns.Bound(e => e.Account_Service_Id).Title("Service#");
                    columns.Bound(e => e.Account_Service_Contract_Id).Title("Contract#");
                    columns.Bound(e => e.CategoryName).Title("Category");
                    columns.Bound(e => e.DepartmentName).Title("Department");
                    columns.Bound(e => e.CommunicationType).Title("Communication");
                    columns.Bound(e => e.Ticket_No).Title("Ticket");
                    columns.Bound(e => e.EnteredByName).Width(100).Title("Entered By");
                    columns.Bound(e => e.Created_Date).Format("{0:M/dd/yyyy}").Title("Create Date");
                    //columns.Bound(e => e.Note_Id).Title("").ClientTemplate("<input type='button'  class='new-subnote-icon' onclick = \"HudsonCustomer().AddNoteClick(this,<#=Note_Id #>," + Convert.ToString(ViewBag.Customer_Id) + ",0,0,0);return false;\"/>");
                    //columns.Bound(e => e.Note_Id).Title("").ClientTemplate("<a href='#' onclick = \"HudsonCustomer().AddNoteClick(this,<#=Note_Id #>," + Convert.ToString(ViewBag.Customer_Id) + ",0,0,0);return false;\">Add Memo</a>");
                }
                 
                )
 
                //.ClientEvents(events => events.OnRowDataBound("notes_onRowDataBound"))
                .DetailView(details => details.ClientTemplate(
                     Html.Telerik().Grid<Hudson.WebApplications.Navigator.IModels.IMemo>()
                                    .Name("Memos")
                                    .Columns(columns =>
                                    {
                                        columns.Bound(o => o.MemoId).Width(100);
                                        //columns.Bound(o => o.EnteredByName).Title("Entered By").Width(50);
                                        //columns.Bound(o => o.Create_Date).Format("{0:M/dd/yyyy}").Title("Create Date").Width (50);
                                        //columns.Bound(o => o.CreateDate).Width(100).Format("{0:M/dd/yyyy}").Title("Create Date");
                                        //columns.Bound(o => o.MemoText).Width(250).Title("Note");
                                        
                                    })
                                    //.ClientEvents(events => events.OnRowDataBound("memo_onRowDataBound"))
                                    .DataBinding(dataBinding => dataBinding.Ajax ()
                                        .Select("LoadMemoForNote", "Note", new
                                        {
                                            noteId = "<#=Note_Id#>"
                                        }))
                                    .Pageable()
                                    .Sortable(s => { s.OrderBy(sortOrder => sortOrder.Add(o => o.Create_Date).Descending()); }).Filterable()
                                    .Filterable()
                                    //.ClientEvents(clientevents => clientevents.OnDataBinding ("OnDataBinding"))
                                    .ToHtmlString()
                                    
 
 
                ))
                .DataBinding(dataBinding => dataBinding
                    .Ajax().Select("GetNotes", "Note", new { customerId = (int)ViewBag.Customer_Id, accountId = (int)ViewBag.Account_Id, serviceId = (int)ViewBag.Service_Id, contractId = (int)ViewBag.Contract_Id })
                )
               .Name("Notes" )
               .Resizable(resizing => resizing.Columns(true))
               .Sortable(s => { s.OrderBy(sortOrder => sortOrder.Add(e => e.Created_Date).Descending());}).Filterable()
               .Pageable(pages => pages.PageSize(20))
               .Footer(true)
                 
               .NoRecordsTemplate("There are no Note to display") 
                .ToolBar(commands =>
                {
                     
                    commands.Custom().ButtonType(GridButtonType.Image).HtmlAttributes(new { style="background-image:url(../../Content/Images/new_note.png);", onclick = "HudsonCustomer().AddNoteClick(this,0," + Convert.ToString(ViewBag.Customer_Id) + ",0,0,0);return false;" });
                    
                }
                )
                
    ;
 
 
    NoteListGrid.Render();
%>

Controller :
[GridAction]
        public ActionResult LoadMemoForNote(int noteId)
        {
            IMemoList memoList = (IMemoList)DependencyResolver.Current.GetService(typeof(Hudson.WebApplications.Navigator.IModels.IMemoList));
            memoList.LoadByNoteId(noteId);
            return View(new GridModel(memoList));
        }

3 Answers, 1 is accepted

Sort by
0
Saul
Top achievements
Rank 1
answered on 25 Jul 2011, 09:47 PM
My co-worker is having the same issue. Please let me know if you figure it out.

Thanks
0
steve_ba14
Top achievements
Rank 1
answered on 21 Nov 2011, 09:43 AM
Did you resolve this? I am having the same issue.

First time load the detail view does not open. However if I refresh the grid with an Ajax call , they do.

<<Updated >> The bug seems to be when I have an Ajax data-binding in place and a model is passed to the grid.
0
Jignesh
Top achievements
Rank 1
answered on 03 Jan 2012, 07:23 PM
The IDs should be unique for all child grid. 
 I have note grid which has multiple Memos in child grid. To make ID unique for child grid I used the ID from parent grid 

.DetailView(details => details.ClientTemplate(
                     Html.Telerik().Grid<Hudson.WebApplications.Navigator.IModels.IMemo>()
                                    .Name("Memos-" + accountId + "-<#=Note_Id#>")
Tags
Grid
Asked by
Jignesh
Top achievements
Rank 1
Answers by
Saul
Top achievements
Rank 1
steve_ba14
Top achievements
Rank 1
Jignesh
Top achievements
Rank 1
Share this question
or