Object doesn't support property or method 'slice'

7 posts, 0 answers
  1. Darryl
    Darryl avatar
    8 posts
    Member since:
    Jun 2014

    Posted 08 Jan 2015 Link to this post

    I am attempting to implement a Kendo DropDownList with server filtering. I have the following in my view (.cshtml):

    @(Html.Kendo().DropDownList()
        .Name("UnselectedADGroups")
        .DataTextField("Name")
        .DataValueField("Name")
        .Filter("StartsWith")
        .DataSource(source =>
        {
            source.Read(read =>
                {
                    read.Action("GetUnselectedADGroups", "ARItemPost");
                }
            )
            .ServerFiltering(true);
        })
    )

    I have the following in my controller:

    public ActionResult GetUnselectedADGroups([DataSourceRequest]DataSourceRequest request, string startsWith)
    {
        try
        {
            var groups = ARItemPost.GetUnselectedADGroups(startsWith);
            var result = groups.ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        catch (Exception e)
        {
            ErrorSignal.FromCurrentContext().Raise(e);
            return null;
        }
    }

    I have verified that I'm getting results back from the AJAX call (it's a collection of a simple object with a single public string property called "Name"), but the dropdown list does not populate and I get an "Object doesn't support property or method 'slice'" error on the "i_pristineData=n.slice(0);" line of [I think] kendo.all.min.js. 
  2. Darryl
    Darryl avatar
    8 posts
    Member since:
    Jun 2014

    Posted 09 Jan 2015 in reply to Darryl Link to this post

    I figured this out. I was approaching this the same way a grid would be bound to a remote data source, but with these list type controls you don't need the DataSourceRequest/Response objects. Instead I just serialized the collection directly and returned that - the DropDownList now works. I would urge the Telerik reps to review the demos for the DropDownList remote data binding and server filtering at http://demos.telerik.com/aspnet-mvc/dropdownlist/remotedatasource and http://demos.telerik.com/aspnet-mvc/dropdownlist/serverfiltering respectively. The controller code shown in both demos has absolutely nothing to do with remote data binding nor server filtering and is, I think, an error of omission. Had those demos been complete I don't think I would have experienced my initial confusion and resulting issues.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 11 May 2015 in reply to Darryl Link to this post

    Thanks Darryl

    To the Telerik Team: I waste a lot of time due to the fact

    a) that remote datasources are handled differently depending on which widget you use (which from proper modular software design aspects is HELL)

    b) that the documentation is far from beeing systematic.

    For this particular Problem of a drop down list editor in a Grid my solution was (after wasting 4 hours finding it out):

    1) do not use "type: odata" although I had a beautiful Odata Service for exactly the data required

    2) prepare a separate json service that serves the data as a list, this because Kendo NEVER calls the data functions in the schema description to extract the data for the list properly.

    This is not a professional API's behaviour! Please, Telerik Team: Clean up the datasource code and provide homgeneous usage of the datasource in EVERY widget. By being consistent, you can systematically document the api and once someone has understood the (though important) datasource concept, he or she does not need to read through inumberable examples and stackoverflow posts get it to work. And really: if I build a OData Web Service Infrastructure, there is no sense in serving the same data on a second address via simple JSON. Or do I miss a point here???

    Regards

    Martin

  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 13 May 2015 Link to this post

    Hello Martin,

    Thank you for the feedback. Indeed there is a difference between CRUD "enabled" widgets (like Grid, ListView and etc) and "read-only" widgets, like DropDownList for instance.

    A simpler "read-only" data source builder was implemented for the so called "read-only" widgets in order to bind them only to a data list (the total field was not required for instance). Thus we insured an easier upgrade path for the developers that were using Telerik extensions for ASP.NET MVC (the library before Kendo UI). 

    I agree with you that providing a consistent configuration is better and will be better for developers that starts with the library. Unfortunately, such modification will be a major breaking change that we cannot introduce without the support of the community. That being said, would it be possible to share your thoughts and suggestion in our Feedback portal?

    With regards to the specific question, the widget can be bound to a ODATA service as it is shown in our Kendo UI demos. What you need to do is to specify the concrete data source type using custom DataSource builder. You can find more details about different DropDownList binding options in its Overview help topic.

    Regards,
    Georgi Krustev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 13 May 2015 in reply to Georgi Krustev Link to this post

    Hi Georgi
     
    Thank you for this clarification. In this regard I have another brain-teaser for you :

    If you have a Grid with a Odata data source containing a column with a dropdown list, again with a remote data source : how would you implement the server backed order by and filter operations? Order by on the grid data source is not the solution as it sorts the keys (guid!) and not the values. Is there any standard solution for that in the framework?

    Best regards

    Martin

  7. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 13 May 2015 in reply to Georgi Krustev Link to this post

    Hi Georgi

    Thank you for this clarification. In this regard I have another brain-teaser for you :

    If you have a Grid with a Odata data source containing a column with a dropdown list, again with a remote data source : how would you implement the server backed order by and filter operations? Order by on the grid data source is not the solution as it sorts the keys (guid!) and not the values. Is there any standard solution for that in the framework ?

    Best regards

    Martin

  8. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 15 May 2015 Link to this post

    Hello Martin,

    Would it possible to share a bit more information, which will help us to get a better understanding of the case? Do you need to sort and filter the data in the ODATA service? Is the question is related to the Grid or to the DropDownList widget? What is the structure of the data that you want to manupulate?

    Regards,
    Georgi Krustev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready