Use Publish Data object to click Attribute Table widget buttons
Greetings! Not a question, but thought I would share something I figured out.
I wanted to click the Export selected to CSV & Clear selection buttons in the Attribute Table widget, within various points in my Workflow.
To do this I modified the Attribute Table’s Widget.js file to look like below:
onReceiveData: function(name, source, params) {
/*jshint unused:vars*/
if (params && params.target === "AttributeTable") {
if (this._isOnlyTable()) {
if (this.state === 'closed') {
console.warn('Please open Attribute Table!');
return;
}
}
params.layer = params.layer || params.layerInfo;
params.closeable = true;
params.isActive = true;
if (!this.showing) {
this._openTable().then(lang.hitch(this, function() {
var isInResources = !!this._resourceManager.getLayerInfoById(params.layer.id);
if (!isInResources) {
this._resourceManager.updateLayerInfoResources(false)
.then(lang.hitch(this, function() {
this._addLayerToTable(params);
}));
} else {
this._addLayerToTable(params);
}
}));
} else {
this._resourceManager.updateLayerInfoResources(false)
.then(lang.hitch(this, function() {
this._addLayerToTable(params);
}));
}
}
//CUSTOM ----------------------------------------------------------------------------------------------------------------------------------------
else if (name == "WorkflowRunner_Panel") {
if (params.action && params.action === "onExportCSVClickAT") {
this._activeTable.onExportCSVClick();
console.log('Log: Success! Exported selected parcels!');
} else if (params.action && params.action === "onSelectionClearAT") {
var btnClearSelection = document.getElementById("dijit_form_Button_1_label");
btnClearSelection.click();
console.log('Log: Success! Cleared selected parcels!');
}
}
// --------------------------------------------------------------------------------------------------------------------------------------------
},
Then when I wanted to click the Export selected to CSV button, I added the Publish Data object in my workflow with the Data set as: ={ action: "onExportCSVClickAT" }
And when I wanted to click the Clear selection button, I added the Publish Data object in my workflow with the Data set as: ={ action: "onSelectionClearAT" }
Hopefully this saves y'all some time! Happy Monday!
Du måste logga in om du vill lämna en kommentar.
Kommentarer
0 kommentarer