Author Topic: Export to Excel with Checkbox Column  (Read 4180 times)

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Export to Excel with Checkbox Column
« on: March 24, 2016, 07:58:51 pm »
I've got a column of checkboxes in my grid for row selection.  I've used the Export to Excel feature before (following your demos) and it usually works fine.  It's not working in my current grid and I'm wondering if it's because I've got this checkbox column.  I'm getting the following error "Cannot read property 'text' of null" in pqgrid.min.js.  I've tried setting copy:false in the colModel for the checkbox column but it hasn't fixed it.

Do you think I might be looking in the wrong place for my mistake?

( Still on version 3.2.0)

Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Export to Excel with Checkbox Column
« Reply #1 on: March 25, 2016, 04:03:42 pm »
I couldn't find the issue, checked by adding export button in the toolbar of this demo: http://paramquery.com/pro/demos32/selection_checkbox,

Code: [Select]
              {
                        type: 'button',
                        label: "Export to Excel",
                        icon: 'ui-icon-document',
                        listeners: [{
                            "click": function (evt) {
                                $( ".selector" ).pqGrid("exportExcel", { url: "/pro/demos/excel", sheetName: "pqGrid sheet" });
                            }
                        }]
                }

Please try to reproduce the issue in the demos and share the steps to do it or share a test case in attachment or a jsfiddle.
« Last Edit: March 25, 2016, 04:07:26 pm by paramquery »

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Export to Excel with Checkbox Column
« Reply #2 on: March 28, 2016, 11:15:42 pm »
I've been able to narrow it down, but I can't see the specific data type which is causing it to fail.  How it comes about is like this...

I am using a remote database to fill the grid. 

If I fill the grid with 'good' data where all entries seem to be string, integer, and even 'undefined' the Excel export works fine.

But if I use a 'left outer join' which populates all the data from a 'master' table and only some of the grid cells receive matching data from the 'subtable' I think the export function doesn't like the format of some (or all) of the empty grid cells.  In this event it will not export to Excel and throws the error mentioned in the original post. 

I don't know whether the empty grid cells are 'null', empty string, empty string where integer is expected or whatever, but if I apply a filter after the data is loaded so that all the empty cells are removed then it will export to Excel once again.

I will experiment to try to determine which datatype is in the empty cells and causes the fault, but it would also be helpful if you can identify from your source code what sort of datatype would cause your export function to fail.  Hopefully we can the draw the same conclusion.

I hope this extra description is useful.