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

ParameterMap on read

4 Answers 246 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 11 Dec 2013, 05:00 AM
I'm trying to modify the remote data schema to the local model in a datasource.  I'm using a parameterMap and its is working correctly for UPDATE, DESTROY, and CREATE methods... so i know its firing correctly.  However, on READ the data object is simply an empty object.   So I here i can't modify the remote data to conform to the local model.

I've found a workaround by using the requestEnd event of the data source... but I'd prefer to keep the logic withing the transport object which seems more appropriate.

4 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 11 Dec 2013, 12:51 PM
Hi Mark,

The parameterMap function is designed to make the request data suitable for the remote service, so this behavior is expected. The data object is empty because it contains the data that will be sent to the server and in case of read operations there is none. Basically the transport.read, create and etc. could be either an object, a string or a function. You could set the transport CRUD operations as functions - this will allow you to make Ajax requests and transform their responses as necessary.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 11 Dec 2013, 05:09 PM
Thanks but this seems a bit asymmetrical.  Clearly if the server expects data in a certain format that is different than the model's definition, it would likely also RETURN data in that same differing format.  Given that what is considered the appropriate way to modify remote data to local data structures since parameterMap only converts to the remote format?

Sounds like the requestEnd could handle that, or building a custom function for that would work, but that seems overly verbose and more error prone.

I would think simply passing the result of the read to the parameterMap funciton would be more straightforward and consistent.
0
Alexander Popov
Telerik team
answered on 12 Dec 2013, 10:43 AM
Hello again Mark,

I missed an important point and I apologize for that. Although using functions for the CRUD operations will work, there is a better approach - using the schema.parse function. It is basically the same as parameterMap, but it is intended to convert the incoming data to a suitable format.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
John
Top achievements
Rank 2
answered on 29 Aug 2015, 01:09 AM
I found a better answer here: http://www.telerik.com/forums/how-to-have-parametermap-override-but-keep-odata-filters
Tags
Data Source
Asked by
Mark
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Mark
Top achievements
Rank 1
John
Top achievements
Rank 2
Share this question
or