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

Model - options.fields.fieldName.from description not clear

1 Answer 204 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jacques
Top achievements
Rank 2
Jacques asked on 13 Nov 2013, 05:11 AM
The Kendo documentation describes the above property as follows: 
"Specifies the field of the original record which value to be used for population of the Model field."

I don't quite understand what is meant here. Can someone describe what this property is actually for? 

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 15 Nov 2013, 08:37 AM
Hello J.Hoventer,

The option is supposed to get the value from the specified field in the raw JavaScript object and store it in a field of the model with a different name. Here is an example:
<script>
    var Product = kendo.data.Model.define( {
        id: "id",
        fields: {
            id: { type: "number", editable: false },
            importedField: {
                type: "string",
                from: "bar"
            }
        }
    });
    var dataSource = new kendo.data.DataSource({
        data: [{ id: 1, bar: "bar" }],
        schema: {
            model: Product
        }
    });
    dataSource.read();
    console.log(dataSource.at(0)); //output Object {id: 1, importedField: "bar"}
</script>

I hope this information will help.

Regards,
Alexander Valchev
Telerik
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
Jacques
Top achievements
Rank 2
Answers by
Alexander Valchev
Telerik team
Share this question
or