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

Updating data for JSON read()

1 Answer 196 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 28 Dec 2011, 12:09 AM
I'm using the Kendo grid to display Elmah errors (test project to evaluate Kendo UI) from a remote data source that gets JSON data from an MVC application. 

I've put a calendar control on the form to filter the data. However, I can't seem to get the read operation to send the parameters. Can anybody figure out what I'm doing wrong? Here is the code:

var errSrc = new kendo.data.DataSource({
    transport: {
        read: {
            url: '@Url.Content("~/Errors")',
            dataType: 'json',
            type: 'post',
            data: function () {
                var d = { day: model.date() };
                return d;
            }
        }
    },
    schema: {
        parse: function (data) {
            if (data.length > 1000) {
                data = data.slice(0, 1000);
                model.tooMany(true);
            }
            var errs = $.map(data, function (item) { return new Error(item) });
            model.errors(errs);
            model.count(errs.length);
            return model.errors();
        }
    }
});

I have confirmed that the data function is getting called and the correct date is being returned. However, no data is being sent in the HTTP post (confirmed using Fiddler2).

I've tried a couple different approaches (such as calling errSrc.read({ day: model.date() })) but haven't gotten it to work yet.

1 Answer, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 28 Dec 2011, 01:02 AM
I think I figured out what I did wrong. After I changed the date to a string, it worked.

var d = { day: model.date().format('{MM}/{dd}/{yyyy}') };

The above code uses Sugar.js for formatting.
Tags
Data Source
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Share this question
or