I am trying to clone a Kendo DataSource into a new DataSource but it seems to be losing any of the options that were set on the old one. I might not be cloning/copying it in the right way though so any suggestions are appreciated.
Here is how I'm currently cloning:
var questionItemGridDataSource = new kendo.data.DataSource(viewModel.baSurveyQuestionItemTemplateDataSource);
questionItemGridDataSource.query({
filter: {
logic: "or",
filters: [
{
field: "BaSurveyQuestionTemplateId",
operator: "eq",
value: questionId
},
{
field: "Name",
operator: "eq",
value: ""
}
]
}
});
It copies it over and sets the filter just fine but if I do
alert(questionItemGridDataSource.options.transport.read.url)
it just alerts undefined
.
EDIT:
I'm aware that I can just set it "manually" by putting
questionItemGridDataSource.options.transport = viewModel.baSurveyQuestionItemTemplateDataSource.options.transport;
afterward, but that just seems unnecessary and there surely is a way to clone a datasource without having to reset the CRUD.
It looks like you are passing a DataSource instance instead of a settings object. Try
var questionItemGridDataSource = new kendo.data.DataSource(viewModel.baSurveyQuestionItemTemplateDataSource.options);