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

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

1 Answer 109 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 08 Jan 2013, 03:00 PM
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

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Jan 2013, 08:53 AM
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!
Tags
Data Source
Asked by
Richard
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or