Return value of custom function into a datasource used in a Kendo grid

#1

Given a kendo grid that use a datasource that has as c3function:“retieveBatchLabel”

reteieveBatchLabel is a function I declared into RevenueOpportunity
In the function I create a generic object that contains as fields the result of different fetches on different types.

In order to display the object properly in the kendo grid - should the function declaration expect a return value or not?
Actually I declared
retrieveBatchLabel: function(spec: FetchSpec): js server
and I do a outcomeArray.push(ro);

and within the function I simply do the return of the array of generic objects and in the kendo grid into the “filed” I’ve put the fields of the object. so far the anything show up

0 Likes

#2

it’s better to return a FetchResult.

0 Likes

#3

In order for your function to return any data you need to declare a return value type.

0 Likes

#4

ok thanks - assuming I’ll return a FetchResult then in the Kendo grid should I put somethting like

returnedObject.objs.field1 to show the field?

0 Likes

#5

You will have a collection or better a DataSource like this:

ui module TheModule {
    dataSource BatchLabels {
        "c3type": "RevenueOpportunity",
        "c3function": "retieveBatchLabel"
        "responseSelector": "objs",
        "c3arguments": {
           "spec": {
                "include": "",
                "filter": "",
                 . . .
                "limit": -1
            }
        }
    }
}

Then in your page or component, use this data source:

        "data": {
            "collection" : "TheModule.BatchLabels"
        },
        "rowIdField": "id",
        "columns" : [
            {
                "label": "the name",
                "field": "name",
                "format": "...",
                "sortable": true,
                ...
            },
            ...
        ]
0 Likes

How to set the default sorted column on a KendoGrid