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

Define a part of fields for remote datasource

1 Answer 71 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Lei
Top achievements
Rank 1
Lei asked on 21 Dec 2012, 06:14 PM
I have a datasource binding to remote data. The model of remote data has many fields. I found that if I do not define schema.model.fields, all fields from remote will be processed, while if I define it, only data in defined fields will be processed. I just want to define part of remote fields, let other fields be defaults.

ds = new kendo.data.DataSource({
    schema: {
        model: {
            id: 'UID',
            fields: {
                UID: { type: 'number', defaultValue: -1 }
                // Can I ignore other 20+ fields?
            }
        },
    },
    transport: {
        read: '/Path/To/ReadData',
create: ...,
update: ...
    }
}

The reason I want to do so is, when I add an item to the datasource then sync, the create action is not triggered. I debugged into source code and found that for the new item, its status is not 'created' since my default value -1 is not equal to "default" defaultValue of ""(empty string). So I think if I could define the id field and ignore other fields, this could be resolved. I know I can define all fields to make it work, but those other fields I don't care. For now, as a workaround, I have to set the id of new item to empty string to make create new item working.

Thanks,

Lei

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 25 Dec 2012, 12:22 PM
Hi Lei,

It is not mandatory to define all the fields of the DataSource - only the ID field is required.
Please have in mind that if you do not define the type of other fields they will be considered and processed (sorted, filtered, etc.) as strings.

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