TypeError: data.slice is not a function

1 Answer 133 Views
TreeList
YL
Top achievements
Rank 1
YL asked on 23 Aug 2024, 08:11 PM | edited on 23 Aug 2024, 08:15 PM

Hi Team,

After upgraded kendo components and using bootstrap 5 as shown below:

"@progress/kendo-theme-bootstrap": "^8.0.1",
"@progress/kendo-ui": "^2024.2.514",
"@types/esprima": "^4.0.5",
"@types/he": "^1.2.2",
"@types/kendo-ui": "^2023.2.5",
  "bootstrap": "^5.2.1",

The export Excel in kendo TreeList triggering an error:

TypeError: data.slice is not a function
    at init.success (kendo.data.js:3858:1)
    at success (kendo.data.js:3748:1)
    at options.success (kendo.data.js:2219:1)
    at fire (jquery.js:3496:1)
    at Object.fireWith [as resolveWith] (jquery.js:3626:1)
    at done (jquery.js:9786:1)
    at XMLHttpRequest.<anonymous> (jquery.js:10047:1)

Here is the code I am using, the exporting Excel is not working, could someone please help ?

@(
Html.Kendo().TreeList<DevelopmentEmployeeDirectoryRemoteModel>()
    .Name("development-tree-list-basic")
    .DataSource(dataSource => dataSource
    .Read(read => read.Url($"{Url.Content("~")}/Development?handler=KendoTreeListDataSourceRead").Data("forgeryToken"))
    .Model(m =>
    {
        m.Id(f => f.EmployeeId);
        m.ParentId(f => f.ReportsTo).Nullable(true);
        m.Field(f => f.FirstName);
        m.Field(f => f.LastName);
        m.Field(f => f.ReportsTo);

    })
    .ServerOperation(false))
    .Columns(columns =>
        {
            columns.Add().Field(f => f.FirstName).Width(250);
            columns.Add().Field(e => e.LastName);
            columns.Add().Field(e => e.Position);
            columns.Add().Field(e => e.Extension).Title("Ext").Format("{0:#}");
        })
    .Toolbar(tools => {                                            
        tools.Pdf();
        tools.Excel();
        tools.Spacer();
        tools.Search();
    })    
    .Excel(excel => excel.FileName("Kendo UI TreeList Export.xlsx").ProxyURL(Url.Action("Excel_Export_Save", "Development")))
    .Pdf(pdf => pdf.FileName("Kendo UI TreeList Export.pdf")
               .AllPages()               
               .PaperSize("A4")
               .Margin("2cm", "1cm", "1cm", "1cm")
               .Landscape(true))
    //.ColumnMenu()
    .Filterable()    
    .Selectable(true)
    .Scrollable(false)
    .Sortable()
    .Resizable(true)
    .Reorderable(true)
    .Deferred(true)
)


 

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 28 Aug 2024, 08:39 AM

Hi YL,

Thank you for the code snippet and the details provided.

In order to achieve the desired behavior, I would recommend using the approach from the following demo with the latest version of the product:

Here is a REPL example:

The following article provides additional information about the Excel export for the TreeList Component:

Give a try to the approach from the above article, demo, and REPL and let me know if this is the desired result.

Kind Regards,
Anton Mironov
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

Tags
TreeList
Asked by
YL
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or