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

Grid in refresh() popup window can't fire databound event

2 Answers 403 Views
Window
This is a migrated thread and some comments may be shown as answers.
HSO
Top achievements
Rank 2
HSO asked on 23 May 2013, 04:57 AM
Hello:

this is the continue of my previous post: No scrollbar on tablets when window is created by Refresh()
however this is a different issue, not about srollbars, so i am opening a new thread.

The popup is generated by calling refresh() method, because I need to pass in a parameter dynamically, this is working all fine.  The problem is in this popup, I have a Kendo Grid, and it needs to fire the DataBound event, but it doesn't work.  Using F12 in chrome, under 'Console', it shows this error:

Uncaught ReferenceError: xxx is not defined

where xxx is the databound function name. (see attached screen shot)

however, if popup window is called just by $("#winName").data("kendoWindow").center().open();
the grid inside the popup has databound event works fine.

These are changes I've made to the test.zip project provided by Petur Subev in reply to my previous post.

on Home/About.cshtml:
@{
    ViewBag.Title = "About Us";
}
 
<h2>About</h2>
<p>
     Put content here. ABOUT
</p>
 @(Html.Kendo().Grid<KendoMVCWrappers.Models.Person>()
.Name("gridEle2")
.Columns(cols =>
{
    cols.Bound(e => e.Name)
        .ClientTemplate("<span id='btn_#=PersonID#' >#:PersonID#</span>");
 
    cols.Bound(e => e.Name)
        .ClientTemplate("<span id='btn2_#=PersonID#' >#:PersonID#</span>");
      
})
.DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("GetPeople", "Home").Type(System.Web.Mvc.HttpVerbs.Post))
)
.Events(events => events.DataBound("xxx"))
)
    
<script>
    function xxx(e) { alert('xxx');}
 
</script>
 
 
<p>
кст. Неговите корени са в класическата Латинска литература от 45г.пр.Хр., ... ...
</p>





I am using kendo version of 2013.1.514

please advise,
Thank you



2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 27 May 2013, 07:10 AM
Hi Jason,

 
From the provided code it seems that the Grid code is executed before the "xxx" function is loaded by the browser, resulting in exception. After moving the DataBound event handler code before the Grid initialization code the project works as expected:

<script>
    function xxx(e) { alert('xxx'); }
  
</script>
 
@(Html.Kendo().Grid<KendoMVCWrappers.Models.Person>()
    .Name("gridEle2")
    .Columns(cols =>
    {
        cols.Bound(e => e.Name)
            .ClientTemplate("<span id='btn_#=PersonID#' >#:PersonID#</span>");
  
        cols.Bound(e => e.Name)
            .ClientTemplate("<span id='btn2_#=PersonID#' >#:PersonID#</span>");
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetPeople", "Home").Type(System.Web.Mvc.HttpVerbs.Post))
    )
    .Events(events => events.DataBound("xxx"))
)
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
HSO
Top achievements
Rank 2
answered on 30 May 2013, 03:13 AM
That works! thank you
Tags
Window
Asked by
HSO
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
HSO
Top achievements
Rank 2
Share this question
or