ParameterMap on read

5 posts, 0 answers
  1. Mark
    Mark avatar
    5 posts
    Member since:
    May 2011

    Posted 10 Dec 2013 Link to this post

    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.

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 11 Dec 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Mark
    Mark avatar
    5 posts
    Member since:
    May 2011

    Posted 11 Dec 2013 Link to this post

    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.
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 12 Dec 2013 Link to this post

    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!
  6. John
    John avatar
    7 posts
    Member since:
    Jul 2014

    Posted 28 Aug 2015 Link to this post

    I found a better answer here: http://www.telerik.com/forums/how-to-have-parametermap-override-but-keep-odata-filters
Back to Top
Kendo UI is VS 2017 Ready