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

查看:28
本文介绍了如何使用像“/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.

为您要执行的操作编写 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天全站免登陆