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

Typescript definition missing DataSource.transport.cache

4 Answers 48 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 01 Sep 2016, 10:54 PM

I am using transport.cache for in-memory caching as described here: http://www.telerik.com/forums/query-caching#wDRMJ8_URkaUjJjENfnBcQ

I am converting my existing JavaScript to TypeScript, and here is the code I am using.

var dataSource = new kendo.data.DataSource({
    type: "webapi",
    transport: {
        read: "../api/companies/",
        cache: "inmemory"
    },
    schema: {
        data: "data",
        total: "total",
        errors: "errors"
    }
});

TypeScript won't compile the code because the cache property is not included in the DataSourceTransport interface.  Is this something that can be fixed?  If there is a different way I should be going about this, please advise.  For now, I've just modified my local copy of the definition file.

Thanks,

Joel

 

 

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Sep 2016, 06:37 AM
Hello Joel,

The cache property is not added in the TypeScript definitions because it is part of the options supported by jQuery.ajax. As stated in our documentation, you can set all options supported by jQuery.ajax. This options can vary, depending on the jQuery version, that is way this option is not included in the documentation:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read

I can suggest using this options directly from $.ajax:

http://api.jquery.com/jquery.ajax/

Let me know if you need additional information on this matter.

Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Joel
Top achievements
Rank 1
answered on 16 Sep 2016, 10:12 PM

Hi Stefan,

I think you are confusing transport.cache with transport.read.cache.  transport.cache is the feature described in the link of my original message.  transport.read.cache is the jQuery.ajax option that serves a different purpose, and it is actually included in the TypeScript definition.  I was hoping transport.cache could get added to the official definition, something like...

interface DataSourceTransport {
    create?: DataSourceTransportCreate;
    destroy?: DataSourceTransportDestroy;
    push?: Function;
    read?: DataSourceTransportRead;
    signalr?: DataSourceTransportSignalr;
    update?: DataSourceTransportUpdate;
    cache?: string;  //missing property
 
    parameterMap?(data: DataSourceTransportParameterMapData, type: string): any;
}

 

Thanks,

Joel

0
Accepted
Stefan
Telerik team
answered on 20 Sep 2016, 10:56 AM
Hello Joel,

The transport.cache property is private and it is not part of the documentation for the Public API of the DataSource. That is why this is not part of the DataSourceTransport interface.

The developers' team does not have short or middle term plans to expose the property.

Apologies for the inconvenience this may cause you.

Regards,
Stefan
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Joel
Top achievements
Rank 1
answered on 15 Nov 2016, 12:01 AM

As a follow up... you can work around this issue by referencing the options.transport object using a variable of type "any". This bypasses the type checking for that variable and allows the setting of the cache property.

 

 

let dataSource = new kendo.data.DataSource({
    type: "webapi",
    transport: {
        read: "../api/companies/",
        //cache: "inmemory"
    },
    schema: {
        data: "data",
        total: "total",
        errors: "errors"
    }
});
let transport: any = dataSource.options.transport;
transport.cache = "inmemory";
Tags
Data Source
Asked by
Joel
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Joel
Top achievements
Rank 1
Share this question
or