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

DataSourceRequest Filters and Sorts fields null? Here is the solution!

13 Answers 2109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 16 Dec 2012, 06:38 PM
I have been trying, for several days, to write HTML/JQuery that calls my ASP.Net MVC Controller and populates the DataSourceRequest structure properly. No matter what I tried, the values in the request for Filters and Sorts were null even though the paging information was present. I consulted the documentation and I found this unhelpful information in the DataSource documentation.

type String
Loads transport with preconfigured settings. Currently supports only "odata" (Requires kendo.data.odata.js to be included).

Eventually I gave up and did, with hindsight what I should have done first, and that was to write a small test case using the helpers to see what it generated. And lo and behold MAGIC. If the type: attribute of the dataSource is set to aspnetmvc-ajax the DataSourceRequest fields are magically populated. So a code snippet is:
$("#grid").kendoGrid({
    dataSource: {
        type: aspnetmvc-ajax,
...
    }
})
Now I am going to have a little gripe. A year ago i started using the Telerik Controls for ASP.Net and I was blown away by them - they were awesome and, for the most part I found the support pretty good. Because I was so impressed as I migrated to MVC I decided to move to Kendo UI because it seemed to be a very clean interface and I had been impressed by the earlier controls.

But it has proven to be a disaster. The product is inherently brilliant. But it's clearly not finished and, if you are like me, and work alone, it can be a nightmare solving each problem as it occurs one at a time. I'd like to say the forums help, and sometimes they do, but there are a depressing number of posts that have one of the following characteristics.
  1. They go unanswered for weeks, if not months - in fact it is not uncommon to see a follow up a week or so later by the original poster about how they eventually circumvented the problem.
  2. A Telerik employee posts nothing but a link to the documentation. The documentation is dreadful. It follows in the path of Microsoft documentation by which I mean if you already know the answer, or at least where to find the answer, it often answers your question. But if you have a "Where do I start with this?" type of question it is generally hopeless.The examples are like most examples in most books,- that is they are fairly simple and most of what developers do isn't simple. And the tricky parts are never answered.
As I suggested in a post several weeks ago, Telerik needs to commission someone like APress to write a book about Kendo UI so that someone who enjoys writing and explaining things can write some good documentation. I'd buy that book, or even better, I'd subscribe to an online version of it that was kept up to date as bugs were fixed and features added. Most developers, myself included, hate writing documentation and, in general, we are not good at it. 

Anyway, there are my two roubles worth - overall, I love the product, but it has made this project I am working on very late. I wish I had stuck to regular ASP.Net with Telerik. But in the end I hope the pain will have been worth it.

13 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 20 Feb 2013, 07:28 PM
Amen!  And thanks for posting this solution. It is exactly what I needed.
0
Kuljit
Top achievements
Rank 1
answered on 09 May 2013, 05:43 AM
Thanks a Lot!!! It saved a lot of trouble.
0
Nick
Top achievements
Rank 1
answered on 15 May 2013, 04:23 PM
Do you know how I can do this via the server-side helpers?

Many thanks.
0
Martin
Top achievements
Rank 1
answered on 15 May 2013, 04:34 PM
It's a long time since I posted this but I think that is what the server side helpers generate if you specify an Ajax source. So I am not sure I understand the question.. In other words, I used the server side helpers to find out what was generated.
0
Nick
Top achievements
Rank 1
answered on 16 May 2013, 09:13 AM
The fundamental problem I have is that the Sorts propery of the DataSourceRequest is null in the controller, even though the information has been specified in the query string.
This is the URL that is being generated: http://localhost:54147/Data/Registration/GetSpreadsheetRegistrations?take=10&skip=20&page=3&pageSize=10&sort%5B0%5D%5Bfield%5D=Location&sort%5B0%5D%5Bdir%5D=asc

And this is in my view:
@(Html.Kendo().Grid(Model.SubModel.Registrations)
         .Name("SpreadSheetRegistrationsGrid")
         .Columns(columns =>
             {
                 columns.Bound(p => p.Location).Sortable(true);
                 columns.Bound(p => p.Exam);
                 columns.Bound(p => p.Venue);
             } )
         .Pageable(pagable => pagable.Enabled(true))                                  
         .Sortable(sortable => sortable.Enabled(true).AllowUnsort(true))
         .Scrollable()
         .Filterable()
         .HtmlAttributes(new { style = "height:370px;" })
         .DataSource(dataSource => dataSource
                                       .Ajax()
                                       .PageSize(10)                                                           
                                       .Read(read => read.Action("GetSpreadsheetRegistrations", "Registration"))
         ))

that is being generated:
So I'm specifying .Ajax(). I just kind of expect this to "just work"...

I saw your post and wondered if there was a way to inject the equivalent of "type: aspnetmvc-ajax" into the data source.

 

 

0
Nick
Top achievements
Rank 1
answered on 16 May 2013, 11:04 AM
It turned out that the JavaScript imports on my page were not set up correctly.

There was a missing import for kendo.aspnetmvc.min.js.
 
It's now working! :-)

 

 

0
Martin
Top achievements
Rank 1
answered on 16 May 2013, 12:49 PM
Glad you got it sorted out.
0
Armin
Top achievements
Rank 1
answered on 17 Nov 2014, 01:47 AM
It's amazing how stupid this problem is! Thank you very much!
0
James Edgell
Top achievements
Rank 1
answered on 03 Oct 2016, 12:48 PM
The lack of documentation, especially on JSP Wrappers is still an issue...
0
T. Tsonev
Telerik team
answered on 05 Oct 2016, 12:28 PM
Hi,

I'd like to ask you to open a separate thread for the issues you've encountered in the JSP documentation. I'll close this thread for the moment.

Regards,
T. Tsonev
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Tuan
Top achievements
Rank 1
answered on 03 Dec 2016, 04:37 PM
My goodness, why they don't have it documented. Thanks a bunch
0
Stefan
Telerik team
answered on 07 Dec 2016, 07:26 AM
Hello Tuan,

I can assume that this is for the undocumented aspnetmvc-ajax type of the DataSource.

If this is correct, the reason is that this is made for the MVC-wrappers where it is used internally, and the user does not need to set it.

Outside of the MVC wrappers, the type can be used but it is not recommended as it has its limitations.

I will forward this to the relevant team for consideration and we can add information in which scenario this property can be used and to describe its limitations.

Any feedback for improving the usefulness of the documentation is greatly appreciated.

Regards,
Stefan
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
0
Xi
Top achievements
Rank 1
answered on 05 Dec 2017, 04:31 PM
Five years gone by, still helping people! Thanks a lot, was almost about to give up.
Tags
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Kuljit
Top achievements
Rank 1
Nick
Top achievements
Rank 1
Martin
Top achievements
Rank 1
Armin
Top achievements
Rank 1
James Edgell
Top achievements
Rank 1
T. Tsonev
Telerik team
Tuan
Top achievements
Rank 1
Stefan
Telerik team
Xi
Top achievements
Rank 1
Share this question
or