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

Grid Helper does not serialize grid content

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 05 Nov 2015, 10:47 AM

Hi,

I'm trying to use the grid component in a huge legacy ASP.NET MVC 5 project. For some reason the ​Html.Kendo().Grid() helper does not serialize my grid's data if I am using it in this project, but it does serialize the data if I use it in a brandnew ASP.NET MVC project.

I used the same source code in the view for both projects:

 

@{
    var dummy = new List<DummyModel>
    {
        new DummyModel
        {
            Col1 = "Foo1",
            Col2 = "Bar1"
        },
        new DummyModel
        {
            Col1 = "Foo2",
            Col2 = "Bar2"
        }
    };
}
 
@(Html.Kendo().Grid(dummy).Name("MyGrid")
      .Columns(col =>
      {
          col.Bound(c => c.Col1);
          col.Bound(c => c.Col2);
      }))

 

In a brand new MVC5 project, this renders  the following html / js code blocks: 

 

 

<div class="k-widget k-grid" id="MyGrid">
 
    <table>
        <colgroup>
            <col/><col/>
        </colgroup><thead class="k-grid-header">
        <tr>
            <th class="k-header" data-field="Col1" data-index="0" data-title="Col1" scope="col">
                <span class="k-link">Col1</span></th><th class="k-header" data-field="Col2" data-index="1" data-title="Col2" scope="col">
                <span class="k-link">Col2</span></th>
        </tr>
        </thead><tbody>
        <tr>
            <td>Foo1</td><td>Bar1</td>
        </tr><tr class="k-alt">
            <td>Foo2</td><td>Bar2</td>
        </tr>
        </tbody>
    </table>
</div>
<script>
    jQuery(function() {
        jQuery("#MyGrid").kendoGrid({
            "columns": [{ "title": "Col1", "headerAttributes": { "data-field": "Col1", "data-title": "Col1" }, "field": "Col1", "encoded": true }, { "title": "Col2", "headerAttributes": { "data-field": "Col2", "data-title": "Col2" }, "field": "Col2", "encoded": true }], "scrollable": false, "messages": { "noRecords": "No records available." }, "autoBind": false,
            "dataSource": {
                "type": (function() {
                    if (kendo.data.transports['aspnetmvc-server']) {
                        return 'aspnetmvc-server';
                    } else {
                        throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                    }
                })(),
                "transport": { "read": { "url": "" }, "prefix": "MyGrid-" },
                "serverPaging": true,
                "serverSorting": true,
                "serverFiltering": true,
                "serverGrouping": true,
                "serverAggregates": true,
                "filter": [],
                "schema": { "data": "Data", "total": "Total", "errors": "Errors", "model": { "fields": { "Col1": { "type": "string" }, "Col2": { "type": "string" } } } }
            }
        });
    });
</script>​

 

This works fine and the table is displayed correctly.

 

​However, in my legacy project this renders the following html / js code blocks: 

 

<div class="k-widget k-grid" id="MyGrid">
    <table>
        <colgroup></colgroup><thead class="k-grid-header"></thead><tbody>
        <tr></tr><tr class="k-alt"></tr>
        </tbody>
    </table>
</div>
<script>
    jQuery(function() {
        jQuery("#MyGrid").kendoGrid({
            "scrollable": false, "messages": { "noRecords": "Keine Aufzeichnungen zur Verfügung." }, "autoBind": false,
            "dataSource": {
                "type": (function() {
                    if (kendo.data.transports['aspnetmvc-server']) {
                        return 'aspnetmvc-server';
                    } else {
                        throw new Error('The kendo.aspnetmvc.min.js script is not included.');
                    }
                })(),
                "transport": { "read": { "url": "" }, "prefix": "MyGrid-" },
                "serverPaging": true,
                "serverSorting": true,
                "serverFiltering": true,
                "serverGrouping": true,
                "serverAggregates": true,
                "filter": [],
                "schema": { "data": "Data", "total": "Total", "errors": "Errors", "model": { "fields": { "Col1": { "type": "string" }, "Col2": { "type": "string" } } } }
            }
        });
    });
</script>

 

The js code is identical to the brand new MVC 5 project, but the html code is missing the serialized data, which results in the table not being displayed correctly. You can easily see this by the fact that the strings "foo" or "bar" are nowhere in the source code.

 

I have double-checked that both projects are using the same Kendo.Mvc.dll reference, so that can't be the problem. I've also read the manual twice on how to set up Kendo UI twice and that did not help, so now I am stuck.

 Thanks in advance for your help,

 Adrian

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Nov 2015, 12:16 PM
Hello Adrian,

I am afraid that the given information is not sufficient to narrow the issue down and point the concrete reason for the missing "columns" configuration. Would it be possible to send us a simplified demo that demonstrates the issue? Thus we will be able to review the problem locally and advice you further.

Regards,
Georgi Krustev
Telerik
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
Adrian
Top achievements
Rank 1
answered on 09 Nov 2015, 03:38 PM

Hello Georgi,

 

Thanks for your reply. I'm sorry, but I can't send you the project, since it is closed source. Also, I cannot reduce the project to a simplified scenario. As mentioned before, the problem does not occur in a new project, so I cannot use that as a starting point. Also, the actual project is really big and contains a lot of references, so it would be too much work to reduce it step by step, looking time and time again for the point where the problem stops occurring. 

 I'm a bit surprised that this kind of problem occurs at all, since it looks very much like a bug in the Kendo UI for Asp.net MVC â€‹helper. Shouldn't the Html helper be free of side effects from other libraries referenced in the same project? What could possibly keep the html helper from serializing the data given to it?

0
Georgi Krustev
Telerik team
answered on 11 Nov 2015, 10:12 AM
Hello Adrian,

We haven't heard of a such strange issue till now, although there are many live applications that uses UI for ASP.NET MVC. This leads me to the thought that something custom is done in the project you are working on that could affect the way HTML helpers work in general.

I am afraid that without a repro demo we cannot do much, as we are in the "guessing" zone.

With regards to your specific questions:

- Shouldn't the Html helper be free of side effects from other libraries referenced in the same project?

Indeed, they are independent from other 3rd party libraries. They depend only on the ASP.NET MVC framework.

- What could possibly keep the html helper from serializing the data given to it?

In general, the widgets will use the ViewContext.Writer to output the widget along with its initialization scripts. I am afraid that I am out of ideas why some options are omitted in your case.

As I said, we will not be able to do much in this case without review a repro demo.

Regards,
Georgi Krustev
Telerik
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
Tags
Grid
Asked by
Adrian
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Adrian
Top achievements
Rank 1
Share this question
or