Uncaught TypeError: e.slice is not a function on data fetch

12 posts, 0 answers
  1. Pavlos
    Pavlos avatar
    7 posts
    Member since:
    Dec 2014

    Posted 09 Oct 2015 Link to this post

    Hi!

    I'm trying to make an ajax call to my controller function.
    To get all the data that currently are in a grid's datasource.
    Instead of calling directly to the grid's datasource.data() which only returns me the current grid page.

    I go about this by instantiating a new kendo datasource.
    But everything i try, yields "Uncaught TypeError: e.slice is not a function"

    Thanks in advance.

    public JsonResult ReadTimeRegistrationAjax([DataSourceRequest] DataSourceRequest request)
    {
       var dataSourceResult = getStuff().ToList();
       return Json(dataSourceResult.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }

    var grid = $("#GridTimeRegistrations").data("kendoGrid");
            var dataurl = grid.dataSource.transport.options.read.url;
     
            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: dataurl,
                        dataType: 'json'
                    }
                },
            });         
     
            dataSource.fetch(function() {
                var data = dataSource.data();
                console.log(data);
            }

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 13 Oct 2015 Link to this post

    Hello Pavlos,

     

    Would it be possible to extract a runnable sample where the issue can be reproduced, as from the code shared here it is not possible for us to tell you why exactly this happens.

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Ashleigh L
    Ashleigh L avatar
    113 posts
    Member since:
    Jun 2012

    Posted 22 Oct 2015 in reply to Pavlos Link to this post

    Happens to me all the time too, what usually fixes it is providing a model for the data:

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: dataurl,
                dataType: 'json'
            }
        },
        schema : {
            type: "json",
            data: "Item",
            model: {
                fields: {
                    Field1: { field: "Field1", type: "number" },
                    Field2: { field: "Field2", type: "number" }
                }  
            }
        }
    });

    (Also, I noticed when copying your code for my example, you've got a comma after the transport closing } that's not necessary).
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 23 Oct 2015 Link to this post

    Hello shimmoril,

     

    Send us a sample of the data that you want to bind, so we can try to recreate the case and see what happens.

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Ashleigh L
    Ashleigh L avatar
    113 posts
    Member since:
    Jun 2012

    Posted 26 Oct 2015 in reply to Kiril Nikolov Link to this post

    I've posted about it before (http://www.telerik.com/forums/datasource-schema-model-for-templates) and didn't receive a helpful answer. Providing the schema model works 100% of the time though, and it's not a big deal to include it, so I dropped the original thread. I just wanted to share what worked for me w/ Pavlos.
  7. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 27 Oct 2015 Link to this post

    Hello shimmoril,

     

    I am happy to hear that you managed to fix the issue that you are having.

     

    And thanks for sharing!

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Pavlos
    Pavlos avatar
    7 posts
    Member since:
    Dec 2014

    Posted 27 Oct 2015 Link to this post

    My appologies, I had submitted a ticket and it got solved there. 
    Like shimmoril suggested adding a model is what did the trick for me.

    I also added a Schema

    schema: {
                    data: "Data",
                    total: "Total"
    ....
    }

    Which solved it for me. Sorry for the late reply I lost track of this post.
    Thanks for following up though!

  9. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 27 Oct 2015 Link to this post

    Hello Pavlos,

     

    Great!

     

    In case you have any further questions, please do not hesitate to contact us.

     

    Regards,
    Kiril Nikolov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  10. Graham
    Graham avatar
    13 posts
    Member since:
    Jul 2012

    Posted 13 Sep in reply to Ashleigh L Link to this post

    To avoid this e.slice error I found that for a grid, my controller had to return as follows:

     

    Json(vehiclesList.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)

     

    Whereas for a DropDownList, EXACTLY the same data had to be returned like this:

     

    Json(vehiclesList, JsonRequestBehavior.AllowGet)

  11. nitesh
    nitesh avatar
    3 posts
    Member since:
    Oct 2016

    Posted 01 Nov Link to this post

    while upgrading kendo.all.js (v2014.3.1411) to (v2016.3.914 ) then getting error e.option.tools.slice .Please help me for same and find attachments.

     

    Thanks

    Nitesh

  12. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 02 Nov Link to this post

    Hi,

    Would it be possible to extract a sample where the issue can be reproduced and send it in a separate ticket? We will be happy to help

    Regards,
    Kiril Nikolov
    Telerik by Progress
     
    Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
     
  13. Pascal
    Pascal avatar
    9 posts
    Member since:
    Mar 2016

    Posted 25 Nov in reply to Graham Link to this post

    Thanks Graham, you helped me solving the "e.slice is not a function" error on a combo box.
Back to Top
Kendo UI is VS 2017 Ready