首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kendoui DataSource odata $expand不工作

Kendoui DataSource odata $expand不工作
EN

Stack Overflow用户
提问于 2013-07-21 10:42:50
回答 3查看 1.7K关注 0票数 0

我有一个绑定到kendoui数据源的移动列表视图,指向一个odata服务。我在数据源配置中有一个$expand提示来展开"Claim“对象的"Patient”属性,但是查看odata查询的url,kendoui数据源并没有在查询字符串中生成$expand代码。如何让kendoui数据源在查询字符串上生成正确的$expand指令?

代码语言:javascript
复制
OData query string genereated: http://localhost:1839/OData.svc/Claim?$callback=jQuery20207924230222124606_1374374358450&%24inlinecount=allpages&%24format=json&%24top=10

<script>
    $(function () {
        var app = new kendo.mobile.Application(document.body, {
            transition: 'slide'
        });

        OData.defaultHttpClient.enableJsonpCallback = true;


        var data = new kendo.data.DataSource({
            type: "odata", // specifies data protocol
            pageSize: 10,  // limits result set
            transport: {
                read: "http://localhost:1839/OData.svc/Claim",
                dataType: "json",
                data: {
                    $expand: "Patient"
                }
            },
            schema: {
                model: {id: "Id"},
                data: function (data) {
                    return data.d.results;
                },
                total: function (data) {
                    return data.d.__count;

                }
            },
            pageSize: 10,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true
        });

        $("#lst").kendoMobileListView(
        {
            template: "<strong>${data.ClaimNumber}</strong><br/>",
            filterable: {
                field: "ClaimNumber",
                operator: "contains"
            },
            dataSource: data
        });
    });
</script>
EN

回答 3

Stack Overflow用户

发布于 2013-09-24 12:54:31

数据和$expand属于read对象。你的答案越来越接近了。

代码语言:javascript
复制
var dataSource = new kendo.data.HierarchicalDataSource({
    type: "odata",
    transport: {
        read: {
            // See http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/ for OData URI conventions
            // OData: ~/api/Users?$inlinecount=allpages&top=2
            // OData: ~/api/Users?$inlinecount=allpages - includes odata.count
            // OData: inline filtering: ~/api/Users?$filter=USERNAME eq 'asgro'
            // to include hierarchical data, use the OData /api/UserGroups?$expand=USER
            // To reduce the payload sice, the query ~/api/UserGroups will only include the USERGROUP entities, and not any navigation property content


            url: "/api/UserGroups",
            data: {
                $expand: "USERS"
            },
            dataType: "json"                                // the default result type is JSONP, but WebAPI does not support JSONP
        },
票数 3
EN

Stack Overflow用户

发布于 2013-07-31 04:09:02

我在transport/read/url中添加了以下内容,而不是单独的数据:

代码语言:javascript
复制
    var dataSource = new kendo.data.HierarchicalDataSource({
        type: "odata",
        transport: {
            read: {
                // See http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/ for OData URI conventions
                // OData: ~/api/Users?$inlinecount=allpages&top=2
                // OData: ~/api/Users?$inlinecount=allpages - includes odata.count
                // OData: inline filtering: ~/api/Users?$filter=USERNAME eq 'asgro'
                // to include hierarchical data, use the OData /api/UserGroups?$expand=USER
                // To reduce the payload sice, the query ~/api/UserGroups will only include the USERGROUP entities, and not any navigation property content


                url: "/api/UserGroups?$expand=USERS",
                dataType: "json"                                // the default result type is JSONP, but WebAPI does not support JSONP
            },
.
.
.
票数 1
EN

Stack Overflow用户

发布于 2020-08-13 04:00:39

代码语言:javascript
复制
read: {
    url: "http://localhost:1839/OData.svc/Claim",
    dataType: "json",
    data: {
        $expand: "Patient"
    }
}

数据只读选项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17768565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档