Author Topic: Adding Filters to Excel Spreadsheets  (Read 2211 times)

arky

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 14
    • View Profile
Adding Filters to Excel Spreadsheets
« on: November 08, 2017, 10:16:52 pm »
Version 4.0.1

Is it possible to add filters to an Excel spreadsheet?

I've tried adding through colModel and by inspection I can see the filter is added, but the sheet doesn't show it.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Adding Filters to Excel Spreadsheets
« Reply #1 on: November 08, 2017, 11:36:14 pm »
If filters added to colModel before import, then pass keepCM: true to importWb() method

https://paramquery.com/pro/api#method-importWb

and if you add filter after import, then call refreshCM() and refresh()

arky

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Adding Filters to Excel Spreadsheets
« Reply #2 on: November 09, 2017, 06:25:33 pm »
Tried that. There seems to be a problem updating the column model in spreadsheets.
Here's what I'm doing trying to change a column width.

             grid.showLoading();
         //import xlsx file from remote location.
         pq.excel.importXl( {url: '<?php echo $url;?>'}, function( wb ){
            grid.importWb({
               workbook: wb,
               extraRows: 0,
               extraCols: 0
            });
            grid.hideLoading();
            var colM = grid.option('colModel');
            colM[2].width= "50%";
            var colM = grid.option('colModel', colM);
            grid.refreshCM();
            grid.refresh();

If that is correct code then it isn't working. Also tried refreshDataAndView()

arky

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Adding Filters to Excel Spreadsheets
« Reply #3 on: November 09, 2017, 08:08:43 pm »
Pardon I figured out my problem.  An offus by oneus error.

I was counting the numberCell column as the 0 dataindx. This had me working on a column that was off screen due to the excessive width I was trying to change, so I didn't see the change.
As far as changing width, this now works nicely.

grid.colModel.width = '50%';
refreshCM();
refresh;

I'm also able to get filters to show which was the original problem
Sorry for the goof but maybe it will help some other poor soul.