So the only event I found for triggering when the new data is loaded is the load event "load( event, ui )". I pulled the export code out of the toolbar listener and put it into the load event instead. The toolbar export button now sets a global 'exporting' flag and changes the page mode. All as below. It works fine, but I wondered if I've overlooked a better way for example adding the load event listener into the toolbar function as a callback? Thanks for your advice or suggestions if you have time.
{
type: 'button',
label: "Export",
icon: 'ui-icon-arrowthickstop-1-s',
listener: function () {
pageModel.type = 'local';
this.option( "pageModel", pageModel);
bExporting = true;
this.refreshDataAndView();
}
myGrid.on("load", function (evt, ui) {
if (bExporting) {
var format = $("#export_format").val(),
blob = this.exportData({
//url: "/pro/demos/exportData",
format: format,
render: true
});
if(typeof blob === "string"){
blob = new Blob([blob]);
}
saveAs(blob, "PartMaster."+ format );
bExporting = false;
pageModel.type = pageModelType;
this.option( "pageModel", pageModel);
this.refreshDataAndView();
}
});