This is a migrated thread and some comments may be shown as answers.

dataSource support $select query option

1 Answer 160 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Art Kedzierski
Top achievements
Rank 2
Art Kedzierski asked on 20 Mar 2014, 04:44 PM
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"
            }
        }
    }
});

1 Answer, 1 is accepted

Sort by
0
Art Kedzierski
Top achievements
Rank 2
answered on 20 Mar 2014, 07:20 PM
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.
Tags
Data Source
Asked by
Art Kedzierski
Top achievements
Rank 2
Answers by
Art Kedzierski
Top achievements
Rank 2
Share this question
or