Export To Excel throwing JS Exception

3 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Dec 2016

    Posted 17 Jan 2017 Link to this post

    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. Nikolay
    Admin
    Nikolay avatar
    104 posts

    Posted 19 Jan 2017 Link to this post

    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.
  3. Daniel
    Daniel avatar
    2 posts
    Member since:
    Dec 2016

    Posted 19 Jan 2017 Link to this post

    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

Back to Top