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

Manually change schema parse

1 Answer 151 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 07 Nov 2013, 06:40 PM
Here is my issue:

I am using the MVC Wrapper for a ListView so I am not setting this up thru javascript and cannot set the schema and columns that way. I need to change the parse function on one of my fields though. Is there any way to do this in javascript before or after the data is loaded? I have gone thru and tried a couple of different places and changed it but its not picking up the new parse.

Basically I need to change a decimal fields default parse from parseFloat to something that will allow it to respect cultures.

any ideas?

1 Answer, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 08 Nov 2013, 02:03 PM
I'm not familiar with the MVC wrappers, but in our code, we (sometimes) update the DataSource's model when receiving data from the server. This is because some of our response payloads include metadata that describes the structure of the data, and we can use that to generate a kendo Model:
var CustomDataSource = kendo.data.DataSource.extend({

    success: function (data) {
        if (_.isUndefined(this.reader.model) && data.metaData) {
            this.reader.model = createModelWithMetadata(data.metaData);
        }
 
        kendo.data.DataSource.success.call(this, data);
    }
}
You might be able to use a similar technique to modify the model with the right parsing functions.
Tags
Data Source
Asked by
Justin
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Share this question
or