Object properties / methods undefined with MVC

2 posts, 0 answers
  1. Todd Fulmino
    Todd Fulmino avatar
    1 posts
    Member since:
    Apr 2010

    Posted 25 Feb 2013 Link to this post

    We are creating an MVC 4 application using the Kendo.Mvc helper assembly. The code is working well; however, we appear to be missing something when we try to obtain a reference to a kendo control.

    Our application has an ActionLink on a toolbar. When the user clicks on the ActionLink, we call into a JS function to validate if the displayed grid has a row selected. Within the function we attempt to obtain a reference to the grid and get the selected row. Unfortunately, the select() function throws an error ("Value is undefined").

    I have included the code below. Most of our logic will be based on controls having the ability to communicate with each other from events, etc. Are we able to receive  the functionality using the MVC assembly, or are we only able to use the API when code in JS?

    Any comments or assistance would be much appreciated.


    .Columns(columns => {
        columns.Bound(o => o.EntityId)
        columns.Bound(o => o.EntityName)
            .Title("Entity Name")
            .ClientTemplate(@Html.ActionLink("#=EntityName#", "Details", "Entity", new { id = "entityId" }, null).ToHtmlString().Replace("entityId", "#=EntityId#"));
        columns.Bound(o => o.TransactionType);
        columns.Bound(o => o.Name)
           .ClientTemplate(@Html.ActionLink("#=Name#", "Details", "Engagement", new { id = "engId" }, null).ToHtmlString().Replace("engId", "#=ID#"));
        columns.Bound(o => o.TransactionStatus);
        columns.Bound(o => o.Initiator);
        columns.Bound(o => o.Reason);  
    .Pageable(p => p.PageSizes(true))
    .Filterable(filterable => filterable
        .Operators(operators => operators
            .ForString(str => str.Clear()
                .StartsWith("Starts with")
                .IsEqualTo("Is equal to")
                .IsNotEqualTo("Is not equal to")
    .Resizable(resize => resize.Columns(true))
    .DataSource(dataSource => dataSource
        .Model(model => model.Id(p => p.ID))
        .Read(r => r.Action("Search", "Transaction")))
    getSelectedRowId: function (gridId) {
                var grid = jQuery(gridId).kendoGrid().data("kendoGrid");
                var row = grid.select();
                if (row.length > 0)
                    return grid.dataItem(row).id;
                    return null;

  2. Nikolay Rusev
    Nikolay Rusev avatar
    2276 posts

    Posted 26 Feb 2013 Link to this post

    Hello Todd ,

    Here is how you should access existing instance of Grid widget:

    var grid = jQuery(gridId).kendoGrid().data("kendoGrid");
    The line above creates new grid widget over existing one and returns reference to it.

    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top