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

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

3 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
syian
Top achievements
Rank 1
Veteran
syian asked on 10 Feb 2021, 04:46 PM
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

3 Answers, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 12 Feb 2021, 01:22 PM

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

0
syian
Top achievements
Rank 1
Veteran
answered on 15 Feb 2021, 04:01 PM

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

 
 
 
 
 
 
 
 
 
 
0
Anton Mironov
Telerik team
answered on 17 Feb 2021, 01:23 PM

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

Tags
Grid
Asked by
syian
Top achievements
Rank 1
Veteran
Answers by
Anton Mironov
Telerik team
syian
Top achievements
Rank 1
Veteran
Share this question
or