Should I create a new DataSource if only the schema model fields need to be changed. ?

2 posts, 0 answers
  1. Richard
    Richard avatar
    148 posts
    Member since:
    Feb 2012

    Posted 08 Jan 2013 Link to this post

    var dataSource = new
    kendo.data.DataSource({
        transport: {
            read: {
                url: window.stpURL + "/GetClusterStoresTable",
                dataType: "xml",
                data: {
                    action: 'fetch',
                    id: function() {
                        return window.selectedFolderNodeID;
                    }
                }
            }
        },
        schema: {
            type: "xml",
            data: "/TABLE/STORES",
            model: {
                fields: fields
            }
        },
        error: raiseXmlDsErrorWindow
    });

    In the above data source the data.id item passed to the read.url is dynamic, that is fantastic.

    My situation is this:
    The schema.model.fields property is also dynamic and can change based on the data.id.
    My understanding from the documentation is that the fields property can't be a function.

    So before I do a ds.read I can query another url to get the fields that will be returned for an id.  Call this 'fieldsOfId'
    If they are different than the current schema.model.fields I should do ... what?

    1. Create a new datasource using the fieldsOfId value.
    or
    2. Change the value of schema.model.fields of that of fieldsOfId and mark the schema/datasource as 'dirty'

    Regardless of how the data source is managed, the Grid that it is attached to will also need to have its columns property adjusted to match the fields of the datasource.

    Thanks,
    Richard DeVenezia
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Jan 2013 Link to this post

    Hello Richard,

     In this case you need to create a new DataSource. Changing the field configuration at runtime is not supported.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top