Bug : Datasource.Transport.Read.Data

4 posts, 0 answers
  1. Stephane
    Stephane avatar
    2 posts
    Member since:
    Nov 2016

    Posted 31 Aug Link to this post

    I notice an error while using Kendo MVC FluentAPI to generate a Datasource with additionnal data in the request URL.

    Using this : 

    ds.Custom().Transport(t => t.Read(r => r.Action("GetUsers", "Application").Data(x => new { IncludeCurrentUser = false })

    generate a javascript property of : 

    "data":{ IncludeCurrentUser = false }

    and result in a javascript error of "Uncaught SyntaxError: Invalid shorthand property initializer"

    The javascript should not be like C# writting but like "data":{ IncludeCurrentUser: false }

  2. Stefan
    Admin
    Stefan avatar
    1145 posts

    Posted 04 Sep Link to this post

    Hello Stephane,

    Thank you for the provided information. This is scenario there is a specific syntax when sending the data which is demonstrated in the following article:

    http://docs.telerik.com/aspnet-mvc/getting-started/custom-datasource#grid-binding-to-odata-v4

    transport.Read(read => read.Url("/odata/Products").Data("{'$expand': 'Category'}");

    The other approach will be to set  JavaScript function as an argument:

    ds.Custom().Transport(t => t.Read(r => r.Action("GetUsers", "Application").Data("customFunction")

    http://www.telerik.com/forums/pass-additional-parameters-to-read-ajax-datasource-method---mvc

    I hope one of these approaches to help to achieve the desired result.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Stephane
    Stephane avatar
    2 posts
    Member since:
    Nov 2016

    Posted 05 Sep Link to this post

    Hi Stefan,

    Yes I know both of the solution, in fact I resolve my problem with your first approach. 

    Still it doesn't resolve the problem when you try to use the Func<object, object> override. There are no documentation anywhere on how to use that override instead of a string params and when I used it the way I thought the javascript generated ain't right.

  4. Stefan
    Admin
    Stefan avatar
    1145 posts

    Posted 07 Sep Link to this post

    Hello Stephane,

    Thank you for the remarks.

    In general, the Visual Studio IntelliSense will show only that the Data method accepts only a function as a string.

    Still, the other approach is also shown in the documentation, but probably not in the most expected place for that functionality.

    We will check this and update the documentation accordingly if needed.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top