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

IE9 server paging not working (Help!!!)

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Marcin asked on 24 Jan 2013, 01:57 PM
Hi all,

Below is a cut of from my JS, CS, etc of how I create the kendo GRID. For IE9 after the read() the ajax call hangs and nothing is populated. On FF, Chrome it works fine. What do I do wrong. Please help.

// templates
<script id="rowTemplate" type="text/x-kendo-template">
    <tr style="height: 24px;">
        <td colspan="1">
           #= Id #
        </td>
    </tr>
</script>
<script id="altRowTemplate" type="text/x-kendo-template">
    <tr class="k-alt" style="height: 24px;">
        <td colspan="1">
           #= Id #
        </td>
    </tr>
</script>

// createGrid
function createGrid(gridId, locale, controller, action) {
    $(document).ready(function () {
        grid = $(gridId).kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "/" + locale + "/" + controller + "/" + action,
                        type: "POST",
                    },
                    parameterMap: function (options) {
                        return JSON.stringify(options);
                    },
                    pageSize: 10
                },
                schema: {
                    data: function (response) {
                        var d = JSON.parse(response);
                        return d.Data;
                    },
                    total: function (response) {
                        var d = JSON.parse(response);
                        return d.Count;
                    },
                    errors: function (response) {
                        if (response.Errors !== undefined) {
                            alert(response.Errors.e.errorThrown);
                        }
                    }
                },
                error: function (e) {
                    alert("Received error: " + e.errorThrown);
                },

                total: 0,
                page: 1,
                pageSize: 10,
                filter: [],

                serverPaging: true,
                serverFiltering: true,
                serverSorting: true,
                serverGrouping: true,
                serverAggregates: true
            },

            autoBind: false,
            groupable: false,
            selectable: true,
            scrollable: false,

            rowTemplate: kendo.template($("#rowTemplate").html()),
            altRowTemplate: kendo.template($("#altRowTemplate").html()),

            pageable: true,
            columns: [{ field: "Id", width: 40, groupable: false, encoded: true }],
        });
    });

    $(gridId).data("kendoGrid").dataSource.read();
}

// controller
[HttpPost]
public string GetEmployees(KendoGridDataSourceRequest request)
{
    if (_usersLoaded == null)
    {
        var users = _userService.FindUsersByName("a%", null, 12);
        _usersLoaded = ViewModelBuilder.CreateEmployeeItemVMList(users).ToList();
    }

    var items = _usersLoaded.Skip(request.Skip).Take(request.Take).ToList();
    var jsonString = JsonConvert.SerializeObject(new
        {
            Data = items,
            Count = _usersLoaded.Count()
        });
    return jsonString;
}

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Jan 2013, 10:23 AM
Hello Marcin,

I assume that the problem is related with JSON.parse function or the JSON response. Could you post a sample of the JSON response that server returns in both cases - when it is working and when it is not?

Generally speaking there should be no need to parse the response on the client if the controller returns a valid JSON. Actually we have a sample project that demonstrates how to configure serverPaging with ASP.NET MVC back-end without wrappers. You can download the source from here.

Please compare your current implementation with the one presented in the sample project.

In addition:
  • the pageSize option should not be duplicated in the transport - it is part of the DataSource object
  • the total is part of the schema and should not be duplication in the DataSource object.

I hope this will help.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Marcin
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or