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

Using 2016.2.630 preview - Data not displayed

7 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 2
Peter asked on 05 Jul 2016, 07:16 PM

I'm trying to work the new preview version for .net core 1.0.  However, the issue I'm having is that the grids will not display any data when using the MVC version.  If I create the grid using the javascript version, it works.

Both grids call the same function and both return data.  However, only Grid2 displays any data. 

Using the KendoUI Chrome plugin, the Kendo Linter gives me two errors on Grid1.

http://localhost:20504/:92,944 Unknown option: prefix
http://localhost:20504/:92,1146 Unknown option: fields

Also, inspecting the grid, the _data for Grid1 shows Array[0], while the _data for Grid2 shows Array[1].

<h1>Grid 1</h1>
@(Html.Kendo().Grid<TelerikCoreTest1.Model.GridModel>()
    .Name("Grid1")
    .Columns(col =>
    {
        col.Bound(x => x.Id);
        col.Bound(x => x.Text);
 
    })
    .DataSource(ds => ds
        .Ajax()
        .Read(rd => rd.Action("Grid_Read", "Home"))
    )
    .Deferred()
)
 
<br />
 
<h1>Grid 2</h1>
 
<div id="Grid2"></div>
 
@section scripts {
 
    <script>
        var readUrl = '@Url.Action("Grid_Read", "Home")'
 
        $("#Grid2").kendoGrid({
            height: 400,
            columns: [{ title: "Id", field: "id" },
                {title: "Text", field: "text"}
            ],
            dataSource: {
                transport: {
                    read: readUrl
                },
                schema: {
                    data: "data"
                }
            }
        });
    </script>
 
    @Html.Kendo().DeferredScripts()
}

public IActionResult Grid_Read([DataSourceRequest]DataSourceRequest request)
{
    List<GridModel> data = new List<Model.GridModel>();
 
    GridModel gm = new GridModel()
    {
        Id = 1,
        Text = "Testing"
    };
 
    data.Add(gm);
 
    return Json(data.ToDataSourceResult(request));
}

7 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 08 Jul 2016, 06:23 AM
Hello Peter,

There is a breaking change in ASP.NET Core, related to how the JSON serializer works. Specific details and suggestions on how to proceed are provided at:

https://github.com/telerik/kendo-ui-core/issues/1856#issuecomment-229874309

https://github.com/telerik/kendo-ui-core/issues/1856#issuecomment-230450923

The server-defined Grid renders a schema.data setting value of "Data", while the server response contains a "data" field. As a result, the client-side Kendo UI DataSource instance cannot parse the response and extract the data items.

Regards,
Dimo
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Peter
Top achievements
Rank 2
answered on 08 Jul 2016, 03:09 PM
Dimo,

Thanks for the info.  That fixed the issue for me. 

0
Michel
Top achievements
Rank 1
answered on 26 Oct 2016, 07:41 AM

Got the same problem with .914 version and solve with the serializer settings.

Would be interesting to update the ui-for-aspnet-mvc-6-demos-rc2-final with the startup.cs modified for solving the json serialize problem.

    services.AddMvc()

.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); 

0
Dimo
Telerik team
answered on 26 Oct 2016, 08:48 AM
Hi Michel,

I am not sure which demos project you are referring to, but in case it is this one:

https://github.com/telerik/ui-for-aspnet-mvc-6-demos

... it has been deprecated and is no longer maintained. 

The current official ASP.NET Core examples that we ship in the installer, contain the discussed fix.

Regards,
Dimo
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Michel
Top achievements
Rank 1
answered on 26 Oct 2016, 11:36 AM

Thank you for your reply.

No I refer to samples I've downloaded elsewhere from  Telerik named actually "ui-for-aspnet-mvc-6-demos-rc2-final".

When installing the .914 version I did not check Samples and after trying to update the installation with the samples, I did not find them in the installation path. Are these samples source available for download elsewhere  (Telerik or Github) ?

Best regards.

0
Dimo
Telerik team
answered on 27 Oct 2016, 10:40 AM
Hello Michel,

Most probably you have downloaded the demos from NuGet or GitHub, but in either case, these demo packages were maintained before ASP.NET Core / MVC6 became official.

Currently the source of MVC examples is the installer, downloadable from telerik.com.

I tested the .914 msi installer for UI for ASP.NET MVC and the offline examples were successfully added on a subsequent install, when the "Change" option was used (not "Repair"). The exact location is:

C:\Program Files (x86)\Telerik\UI for ASP.NET MVC R3 2016\wrappers\aspnetmvc\Examples

Alternatively, download a ZIP installer for UI for ASP.NET MVC and extract the demos from it manually, from the same nested folder, as shown above.

Regards,
Dimo
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Michel
Top achievements
Rank 1
answered on 27 Oct 2016, 11:56 AM

Hi Dimo,

I'm very confuse these samples are at the right place in the wrappers directory. I didn't event know it was were the samples are installed.

Thanks for the clarification, it enhance my skills:)

Best regards.

Tags
Grid
Asked by
Peter
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Peter
Top achievements
Rank 2
Michel
Top achievements
Rank 1
Share this question
or