Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI grid - modify data after request

is there a way to manipulate(transform) data right after the request to the server or before binding? I need to make request to the server, transform result data and then bind that data to the kendo grid.

like image 964
dakt Avatar asked Apr 01 '14 09:04

dakt


1 Answers

Yes, you should use either parse in the schema definition or in the dataBound event.

Example in parse

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: ..
            dataType: "json"
        }
    },
    schema: {
        parse: function(data) {
            // Example adding a new field to the received data
            // that computes price as price times quantity.
            $.each(data, function(idx, elem) {
                elem.price = elem.qty * elem.price;
            });
            return data;
        }
    }
});
like image 110
OnaBai Avatar answered Sep 27 '22 23:09

OnaBai