Author Topic: Go to page 1 after exporting the selected row.  (Read 400 times)

tbum

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Go to page 1 after exporting the selected row.
« on: June 17, 2022, 05:47:57 am »
Hi,
I want to export only selected(cb: checked) rows to excel.

This works fine. However, after exporting data, it moves to page 1.
How can I avoid moving pages?

Code: [Select]
colModel: [
        { dataIndx: "selectRow", maxWidth: 30, minWidth: 30, align: "center", resizable: false,
          title: "",
          menuIcon: false,
          type: 'checkbox',
          sortable: false,
          editor: false,
          dataType: 'bool',
          copy: false,
          cb: {
            all: false,
            header: true
          }
        },
       ...
      ],
selectionModel: { type: 'row' },
toolbar: {
        items: [
          {
            type: "button",
            label: 'export',
            cls: 'btn btn-success my-1',
            listener: function () {
              let dateStr = $.datepicker.formatDate('yymmdd', new Date());
              let format = 'xlsx';

              if( this.Checkbox('selectRow').getCheckedNodes().length >= 1 ) { //If checked, export selected rows.
                this.filter({
                  oper: 'replace',
                  rules: [{ dataIndx: "selectRow", condition: "equal", value: true}]
                });
              }

              let blob = this.exportData({
                sheetName: dateStr,
                format: format,
                render: false
              });
              if(typeof blob === "string"){
                blob = new Blob([blob]);
              }
              this.filter({
                oper: 'replace',
                rules: [],
              });
              saveAs(blob, `${dateStr}.${format}`);
            }
          }
        ]
      }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Go to page 1 after exporting the selected row.
« Reply #1 on: June 17, 2022, 10:39:45 am »
you can use saveState methosd before export and loadState method after export to maintain page number.

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

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

tbum

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Go to page 1 after exporting the selected row.
« Reply #2 on: June 17, 2022, 11:00:12 am »
I solved it! thanks for your reply :)