JQuery: e.slice is not a function on Grid SetDataSource

4 posts, 0 answers
  1. syian
    syian avatar
    12 posts
    Member since:
    Mar 2020

    Posted 10 Feb Link to this post

    I have a Grid with the following DataSource:
    ..
    transport: {
        read: {
            url: "GetJsonData.p",
            data: {
                "function": grid_function,
                "element":  "grid",
                "param1":   grid_param1,
                "param2":   grid_param2,
                "param3":   grid_param3,
                "rowid":    grid_rowid
            },
            dataType: "json"
        }
    },
    schema: {
        data:  "data",
        total: "recordsCount",
        model: {
            id: "field1"
        }
    }
    ...

    I want to be able to update the DataSource when the user selects a row on a different Grid. For that reason, I am using a JS function that uses the SetDataSouce method and passes different values to the getJsonData.p procedure, which then generates the return data:

    function SetGridDS(grid_element,grid_function,grid_param1,grid_param2,grid_param3,grid_rowid) {
        grid_element.setDataSource(new kendo.data.DataSource({
            transport: {
                read: {
                    url: "GetJsonData.p",
                    data: {
                        "function": grid_function,
                        "element":  "grid",
                        "param1":   grid_param1,
                        "param1":   grid_param2,
                        "param3":   grid_param3,
                        "rowid":    grid_rowid
                    },
                    dataType: "json"
                }
            },
            schema: {
                data:  "data",
                total: "recordsCount",
                model: {
                    id: "field1"
                }
            }
        }));
     
        grid_element.dataSource.read();
    }

     

    However, I am getting the e.slice is not a function error. (hence the schema and the model, as suggested by others in the forum - but with no luck).
    Is there a way to better analyse the error and find what exactly is causing it?

    Thank you in advance,
    Syian

  2. Anton Mironov
    Admin
    Anton Mironov avatar
    211 posts

    Posted 12 Feb Link to this post

    Hello Syian,

    Thank you for the code snippets and details provided.

    In general, this error is caused by a wrong parsing of the response. In order to parse it correctly, use the approach from the following article:

    I hope this information helps. If the approach above is not a working solution for your application, send me a runnable sample of your project back in this thread. Examining this project will let us replicate the issue locally and further troubleshoot it.

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

  3. syian
    syian avatar
    12 posts
    Member since:
    Mar 2020

    Posted 15 Feb in reply to Anton Mironov Link to this post

    Hi Anton, 

    thank you for the response.

    You were right about the cause of the error, which made me think again what I wanted to achieve in the first place. I tried your recommendation, but it did not work and I think that was not exactly was I was looking for. I managed to solve the problem by using the read() method, which makes sense - since I am only updating the additional parameters which are send to the remote service:

    function SetGridDS(grid_element,grid_function,grid_param1,grid_param2,grid_param3,grid_rowid) {
        grid_element.dataSource.read({
            "function": grid_function,
            "element":  "grid",
            "param1":   grid_param1,
            "param1":   grid_param2,
            "param3":   grid_param3,
            "rowid":    grid_rowid
        });
    }

     

    I am posting the code in case someone else has the same problem.

    Regards,

    SYian

     
     
     
     
     
     
     
     
     
     
  4. Anton Mironov
    Admin
    Anton Mironov avatar
    211 posts

    Posted 17 Feb Link to this post

    Hello Syian,

    Yes, you are totally correct. Thank you for sharing the approach with the community.

    Feel free to contact me and the team if we could assist you with anything else.

    Best Regards,
    Anton Mironov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top