Typescript definition missing DataSource.transport.cache

5 posts, 1 answers
  1. Joel
    Joel avatar
    16 posts
    Member since:
    Feb 2015

    Posted 01 Sep Link to this post

    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

     

     

  2. Stefan
    Admin
    Stefan avatar
    276 posts

    Posted 06 Sep Link to this post

    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.
     
  3. Kendo UI is VS 2017 Ready
  4. Joel
    Joel avatar
    16 posts
    Member since:
    Feb 2015

    Posted 16 Sep in reply to Stefan Link to this post

    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

  5. Answer
    Stefan
    Admin
    Stefan avatar
    276 posts

    Posted 20 Sep Link to this post

    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.
     
  6. Joel
    Joel avatar
    16 posts
    Member since:
    Feb 2015

    Posted 14 Nov in reply to Stefan Link to this post

    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";
Back to Top
Kendo UI is VS 2017 Ready