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

Why no load event ?

5 Answers 366 Views
Grid
This is a migrated thread and some comments may be shown as answers.
P-A
Top achievements
Rank 1
P-A asked on 19 Sep 2012, 09:51 AM
Hi,

i'm a bit surprised, because i Just moved from Telerik MVC extensions to Kendo UI Complete for MVC, and i noticed that the load event of the grid disappeared.

And if i try to do what i want in the document load event ($(document).ready(......)), the grid is not yet constructed or available if i call it like this :

var

grid = $("#Grid").data("kendoGrid"); => error

Did I miss something ?

 

5 Answers, 1 is accepted

Sort by
0
P-A
Top achievements
Rank 1
answered on 21 Sep 2012, 12:37 PM
Could you please tell how i could go through this ? I really need to know when the grid is constructed
0
Andy
Top achievements
Rank 1
answered on 31 Jan 2013, 08:09 PM
+1 on this. I am looking for a loaded event as well, so that I can get a reference to the control at runtime.

Not just for the Grid, but for DropDownList and other MVC wrappers.

0
Atanu
Top achievements
Rank 1
answered on 01 Feb 2013, 05:33 AM
When using Kendo UI MVC wrappers, the initialization statement follows immediately the widget's HTML markup. So you can put your custom Javascript anywhere after the server-side widget declaration.

For example

@{
    Html.Kendo().Grid<......>()
    .Name("YourGridName")
    blah blah blah
    .......................
    .......................
    .......................
    .Render();
}

<script>
    here goes your on load event on $(document).ready(......)
</script>

Hope that helps.
0
Andy
Top achievements
Rank 1
answered on 05 Feb 2013, 08:14 PM

I'm not seeing that behavior. In the example below, I have js just after the Kendo declaration, and the value of grid is undefined there. The only way I have been able to get the reference to the Grid is in an event such as Change, ColumnResize, etc.

     @(Html.Kendo().Grid(Model)
                .Name("Grid")
                .Columns(columns =>
                {
                    columns.Bound(p => p.RoleName).Width(200);
                    columns.Bound(p => p.Description);
                })
               
                {...}

            )

        <script type="text/javascript">
            var grid = $("#Grid").data("kendoGrid");
        </script>

0
Atanu
Top achievements
Rank 1
answered on 06 Feb 2013, 03:44 AM
Andy,

I have also mentioned the $(document).ready function which you might have missed

Try

@(Html.Kendo().Grid(Model)
  .Name("Grid")
  .Columns(columns =>
  {
     columns.Bound(p => p.RoleName).Width(200);
     columns.Bound(p => p.Description);
  })
                 
 {...}
)
        
<script type="text/javascript">
$(document).ready(function() {
   var grid = $("#Grid").data("kendoGrid");
});
</script>

Hope that helps.
Tags
Grid
Asked by
P-A
Top achievements
Rank 1
Answers by
P-A
Top achievements
Rank 1
Andy
Top achievements
Rank 1
Atanu
Top achievements
Rank 1
Share this question
or