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

Export To Excel throwing JS Exception

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 17 Jan 2017, 04:45 PM
I'm having trouble getting the export to excel working, it throws  Cannot read property 'length' of undefined in jquery

 

Here is MVC Grid Declaration:

@(Html.Kendo().Grid<TransactionViewModel>()
      .Name("completedgrid")
      .Columns(columns =>
      {
          columns.Bound(m => m.StudentCode);
          columns.Bound(m => m.date).Title("Date");
          columns.Bound(m => m.amount).ClientTemplate("#=kendo.toString(data.amount,'c')#").Title("Amount");
      })
      .ToolBar(toolbar =>
      {
          toolbar.Excel();
      })
      .Excel(e =>
      {
          e.FileName("TransactionList.xlsx");
      })
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Read(read => read.Action("StudentPayments_Read", "PaymentsGrid").Data("getCompletedData"))
      )
)

 

In case you need getCompletedData: 

function getCompletedData() {
        return {"id" : @ViewBag.LocationId, "date":sel};
         }

 

sel is just a string containing date information like "01 2017"

TransactionViewModel:

public class TransactionViewModel
    {
        public string StudentCode;
        public decimal amount;
        public string date;
    }

 

Everything seems pretty simple, I can't see what I'm missing. The controller was scaffolded so was the grid. I had to add the filename for the excel export, and I added the date filter.

I tried adding a proxyurl but it didn't change the result so I took it out, assuming its not needed.

Any help is appreciated,
Thank you

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Jan 2017, 12:04 PM
Hello,

I have modified our Export to Excel demo to be similar to your scenario and it works as expected.

Can you please send us an isolated runnable project, where the described problem can be observed, so we can inspect it further, and try to determine what might be causing it? A dojo example will be also helpful.

Thank you in advance.

Regards,
Nikolay
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Daniel
Top achievements
Rank 1
answered on 19 Jan 2017, 04:14 PM

When I tried to create a new project with a new installation of kendo it worked. I thought I was just missing something but I guess there was something up with my kendo installation. Reinstalling it worked.

Thank you very much for your time,

Daniel

Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or