0

My grid won't call my parameterized DataSourceResult methods. It just calls the parameterless one. I've studied this article till my eyes are falling out. What am I missing?

From my javascript controller:

$("#grid").kendoGrid({
    dataSource: {
        transport: {
            read: function (options) {
                userService.getGridUserList($.extend(options.data))
                .success(function (result) { options.success(result); })
                .error(function (result) { options.error(result); });
            },
            parameterMap: function(options, type) {
                return kendo.stringify(options);
            }
        },
        requestStart: function (e) {
        },
        requestEnd: function (e) {
        },
        schema: {
            data: "data",
            total: "total"
        },
        pageSize: 25,
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true
    },
    height: 600,
    filterable: true,
    sortable: true,
    pageable: true,
    columns: [
        { field: "firstName", title: "First Name" },
        { field: "lastName", title: "Last Name" },
        { field: "email", title: "email" }
    ]
});

From my C# WebAPI:

//**doesn't get called**
public DataSourceResult GetGridUserList(GetUserGridListInput input)
{
    var q = repository.GetAll().OrderBy(t => t.Id);
    return q.ToDataSourceResult(input.Take, input.Skip. input.Sort, input.Filter);
}

//**doesn't get called**
public DataSourceResult GetGridUserList(int take, int skip, IEnumerable<Sort> sort, Filter filter)
{
    var q = repository.GetAll().OrderBy(t => t.Id);
    return q.ToDataSourceResult(take, skip, sort, filter);
}

//**gets called every time**
public DataSourceResult GetGridUserList()
{
    var q = repository.GetAll().OrderBy(t => t.Id);
    return  q.ToDataSourceResult(500, 0, null, null);
}
John Mc
  • 212
  • 2
  • 16

2 Answers2

1

Turns out I was clobbering the grid parameters in my service call. What I needed to fix it, is to add {} as the first parameter:

userService.getGridUserList({}, $.extend(options.data))

John Mc
  • 212
  • 2
  • 16
0

The example uses a POST request, perhaps the grid requires that.

"I'm using a POST since MVC blocks unsecured GETS by default. That's good since we're going to be needing a POST request structure coming up shortly."

Nic
  • 12,220
  • 20
  • 77
  • 105