Kendo Grid not calling correct DynamicLINQ method

dynamic-linq kendo-grid kendo-ui

Question

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);
}
1
0
10/2/2014 11:13:23 PM

Popular Answer

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))

1
10/4/2014 4:21:14 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow