asp.net core 3.1 with AspNetzero - grid not binding to data when called from Ajax

2 posts, 0 answers
  1. Prakash
    Prakash avatar
    1 posts
    Member since:
    Jan 2020

    Posted 19 Mar 2020 Link to this post

    The grid definition in asp.net mvc core chtml

    index.cshtml
    @(Html.Kendo().Grid<COSalesDto>()

    .Name("grid")

    .Columns(columns => { columns.Bound(p => p.CatalogNumber); columns.Bound(p => p.UsageCode).Width(150); })

    Pageable() .Sortable() .Filterable()

    .DataSource(dataSource => dataSource

           .Ajax() .PageSize(20)

         .Read(read => read.Action("ChangeOrder_Read", "Naco"))

    ).Deferred() )  

    Here is my data returned from ajax call

    { "Data": [ { "CatalogNumber": "Catalog 12345", "UsageCode": "Usage Code 1" }, { "CatalogNumber": "Catalog 8234758", "UsageCode": "Usage Code 2" } ], "Total": 0, "AggregateResults": null, "Errors": null }

    all events are triggering on grid, but no data binding happening.  Here is my entry in startup

    Startup.cs

    services.AddControllersWithViews(options => { options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute()); })

    .AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNameCaseInsensitive = true; options.JsonSerializerOptions.PropertyNamingPolicy = null; }) 

    Any help greatly appreciated.
    Thanks V


  2. Martin
    Admin
    Martin avatar
    299 posts

    Posted 24 Mar 2020 Link to this post

    Hello Prakash,

    Thank you for the code snippet. 

    On my side, the data is binding correctly if I remove the Deffered() method, which will suppress the immediate rendering of the script statements. Attached you will find a project for reference based on the provided code snippet. If removing the Deffered method does not resolve the issue, could you please modify the project to reproduce the issue? I will then debug it and happily assist you.

    Looking forward to your reply.

    Regards,
    Martin
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top