如何使用像'/update/:id'这样的URL作为KendoUI数据源? [英] How to use URLs like '/update/:id' as KendoUI datasource?

查看:85
本文介绍了如何使用像'/update/:id'这样的URL作为KendoUI数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了文档,但没有发现与dataSource url中的设置参数相关的内容.有可能实现这一目标吗?

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

提前谢谢.

推荐答案

是的,有可能. DataSource.transport中定义的url可能是一个函数.此函数(对于update)接收要更新的数据(模型)作为第一个参数,并返回应用作URL的字符串.

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

这篇关于如何使用像'/update/:id'这样的URL作为KendoUI数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆