Symptoms

What sort of data can be used for aps/Grid? How can I use specific data to be displayed in a grid?

Resolution

You can use both aps/Store and aps/Memory to populate aps/Grid.

If you need to display only some of the resources you can create a Memory and fill it with needed data, here is an example that shows only domains that were not yet added into application.

// create a store to fill with all domains available for account
var allDomainsStore = new ResourceStore({
        target: "/aps/2/resources/",
        apsType: "http://aps-standard.org/types/dns/zone/1.0"
});

// create a store to fill with domains that were added into application, they should not be displayed to the user in this view
var alreadyAddedDomainsStore = new ResourceStore({
        target: "/aps/2/resources/",
        apsType: "http://vendor.com/application/domain/1.0"
});

// comparing two stores
when(allDomainsStore.query(), function(allDomains) {
    when(alreadyAddedDomainsStore.query(), function(addedDomains) {
        var addedDomainsHash = {};
        for (var i = 0; i < addedDomains.length; i++) {
            addedItem = addedDomains[i];
            addedDomainsHash[addedItem.name] = true
        }

        var domainList = [];
        for (var i = 0; i < allDomains.length; i++) {
            domain = allDomains[i];
            if (addedDomainsHash[domain.name]) {
                continue;
            }
            domainList.push({ id: domain.aps.id, label: domain.name, value: domain.aps.id});
        }

        // domainList now contains a list of all domains that were not added into application yet
        domainList.sort(function(a, b) {return a.label >= b.label});
    });
});

Then you can create a Memory from domainList:

var freeDomainList = new Memory({data: domainList, idProperty: "id"});

and use it for Grid:

store: freeDomainList

Internal content