Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use URLs like '/update/:id' as KendoUI datasource?

I read the documentation but found nothing related to setting parameters in dataSource urls. Is it possible to achieve that?

Thx in advance.

like image 299
Isilmë O. Avatar asked Dec 14 '22 20:12

Isilmë O.


1 Answers

Yes, it is possible. The urls defined in the DataSource.transport might be a function. This function receives (for update) as first argument the data being updated (the model) and returns the string that should be used as URL.

Composing the URL for what you want to do is:

var ds = new kendo.data.DataSource({
    transport: {
        read: {
            url: function () {
                return 'read';
            }
        },
        update: {
            url : function (item) {
                return 'update/' + item.id;
            }
        }
    }
});
like image 173
OnaBai Avatar answered Jan 22 '23 20:01

OnaBai