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

13 posts, 0 answers
  1. Martin
    Martin avatar
    39 posts
    Member since:
    Dec 2011

    Posted 16 Dec 2012 Link to this post

    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 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:
        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.

  2. Scott
    Scott avatar
    1 posts
    Member since:
    Nov 2011

    Posted 20 Feb 2013 Link to this post

    Amen!  And thanks for posting this solution. It is exactly what I needed.
  3. Kuljit
    Kuljit avatar
    1 posts
    Member since:
    Mar 2013

    Posted 09 May 2013 Link to this post

    Thanks a Lot!!! It saved a lot of trouble.
  4. Nick
    Nick avatar
    3 posts
    Member since:
    May 2013

    Posted 15 May 2013 Link to this post

    Do you know how I can do this via the server-side helpers?

    Many thanks.
  5. Martin
    Martin avatar
    39 posts
    Member since:
    Dec 2011

    Posted 15 May 2013 Link to this post

    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.
  6. Nick
    Nick avatar
    3 posts
    Member since:
    May 2013

    Posted 16 May 2013 Link to this post

    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:
             .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))
             .HtmlAttributes(new { style = "height:370px;" })
             .DataSource(dataSource => dataSource
                                           .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.



  7. Nick
    Nick avatar
    3 posts
    Member since:
    May 2013

    Posted 16 May 2013 Link to this post

    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! :-)



  8. Martin
    Martin avatar
    39 posts
    Member since:
    Dec 2011

    Posted 16 May 2013 Link to this post

    Glad you got it sorted out.
  9. Armin
    Armin avatar
    1 posts
    Member since:
    Dec 2013

    Posted 16 Nov 2014 in reply to Martin Link to this post

    It's amazing how stupid this problem is! Thank you very much!
  10. James Edgell
    James Edgell avatar
    4 posts
    Member since:
    Sep 2009

    Posted 03 Oct 2016 Link to this post

    The lack of documentation, especially on JSP Wrappers is still an issue...
  11. T. Tsonev
    T. Tsonev avatar
    2791 posts

    Posted 05 Oct 2016 Link to this post


    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.

    T. Tsonev
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
  12. Tuan
    Tuan avatar
    1 posts
    Member since:
    Nov 2016

    Posted 03 Dec 2016 Link to this post

    My goodness, why they don't have it documented. Thanks a bunch
  13. Stefan
    Stefan avatar
    1137 posts

    Posted 07 Dec 2016 Link to this post

    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.

    Telerik by Progress
    Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Back to Top