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

Bug : Datasource.Transport.Read.Data

3 Answers 223 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
David Gomez
Top achievements
Rank 1
David Gomez asked on 31 Aug 2017, 01:59 PM

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 }

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 04 Sep 2017, 06:26 AM
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.
0
David Gomez
Top achievements
Rank 1
answered on 05 Sep 2017, 01:11 PM

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.

0
Stefan
Telerik team
answered on 07 Sep 2017, 07:25 AM
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.
Tags
Data Source
Asked by
David Gomez
Top achievements
Rank 1
Answers by
Stefan
Telerik team
David Gomez
Top achievements
Rank 1
Share this question
or