dataSource support $select query option

2 posts, 0 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 20 Mar 2014 Link to this post

    I'm trying to limit the columns returned by a oData query. Does dataSource support the oData $select query option? I was able to get $expand working and it was implemented at the same time, I recall. This is what I'm attempting, but I'm not sure if I'm implementing $select correctly.

    var gridDataSource = new kendo.data.DataSource({
        type: "odata",
        schema: {
            data: function (data) {
                if (data.value) {
                    return data.value;
                }
                delete data["odata.metadata"];
                return [data];
            },
            total: function (data) {
                return data["odata.count"];
            }
        },
        pageSize: 10,
        scrollable: false,
        sort: { field: "Name", dir: "asc" },
        transport: {
            read: {
                url: "/GLMEntitiesModelService.svc/Devices",
                data: {
                    $expand: "Location",
                    $select: "ID,LocationFK,Name,Vendor,Product,Component"
                }
            }
        }
    });
  2. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 20 Mar 2014 in reply to Art Kedzierski Link to this post

    Somehow I made it work after all, even limiting columns returned from the related table. I tested a constructed URL in the browser first:

    http://localhost:63385/GLMEntitiesModelService.svc/Devices(2)?$expand=Location&$select=ID,Name,Vendor,Product,Component,Location/ID,Location/Name

    Then reconstructed that via dataSource.transport.read.data:

    transport: {
        read: {
            url: "/GLMEntitiesModelService.svc/Devices",
            data: {
                $expand: "Location",
                $select: "ID,Name,Vendor,Product,Component,Location/ID,Location/Name"
            }
        }
    }

    MUCH faster results with limiting columns returned.
  3. Kendo UI is VS 2017 Ready
Back to Top