viewmodel from post - unable to bind in kendo Grid

2 posts, 0 answers
  1. E
    E avatar
    1 posts
    Member since:
    Dec 2020

    Posted 06 Dec 2020 Link to this post

    I am struggling for last 3 days. all nugets installed.. and contoller is doing all that needs to do and returning viewmodel back to index view. but kendo grid doesn't render any thing. code below. am i doing any thing wrong here?

    **************************************************************************************

    @model Icaew.StudentRegistration.Admin.WebApp.Models.UserSearchViewModel
    @using Kendo.Mvc.UI
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.common.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.rtl.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.silver.min.css" />
    <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2017.1.118/styles/kendo.mobile.all.min.css" />
    <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="http://kendo.cdn.telerik.com/2017.1.118/js/kendo.all.min.js">
    </script>
    <main class="primary content">    
        <div class="row">
            <div class="columns">     
                @if (Model != null && ViewBag.UsersCount >= 1 && !Model.HasError)
                {
                    @(Html.Kendo().Grid(Model.SearchResult)
                            .Name("grid")
                            .DataSource(dataSource => dataSource
                                .Ajax()
                                .PageSize(2)
                                .ServerOperation(false)
                             )
                            .ToolBar(tools =>
                            {
                                tools.Pdf().Text("Custom PDF button text");
                                tools.Excel().Text("Custom Excel button text");
                            })
                            .Pageable()
                            .Sortable()
                            .Groupable()
                            .Columns(columns =>
                            {
                                columns.Bound(f => f.RecordCode);
                                columns.Bound(f => f.Firstname);
                            })
                   )
                }
                <a asp-area="" class="cta-link" asp-controller="Home" asp-action="Index">Back</a>
            </div>
        </div>
    </main>
    ************************************************************************************************************************************

    please can anyone help me? am i not including any css or js?

  2. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    1082 posts

    Posted 09 Dec 2020 Link to this post

    Hello,

    Thank you for the provided snippets.

    The grid definition appears to be as expected but the scripts and styles are outdated and also the kendo.aspnetmvc.min.js is missing which is likely causing a kendo.syncReady is not a function error in the console. You can verify this by opening the Developer Tools with F12 and checking the console tab.

    I am attaching here an ASP.NET Core sample project using the same configuration as you have shared for your reference.

    Let us know in case you need further assistance.

    Regards,
    Alex Hajigeorgieva
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top