Pass parameter to method associated to click of a button in diff section
Hello!
how are you?
I hope your can help me!
I have a button in EmployeePage, when I press the button call to method "downloadFile" in property "click". I want call to this method from various bottons but passing a distinct parameter for each button. Example:
{ "operation": "insert", "name": "DownloadFileButton", "values": { "itemType": 5, "imageConfig": { "bindTo": "Resources.Images.FilesImage" }, "click": { "bindTo": "downloadFile" //Pass parameter }, "visible": true "enabled": { "bindTo": "UsrClaveAltaTemprana" }, //Button Tooltip "hint": { "bindTo": "Resources.Strings.MensajeTooltipDownload" }, "markerValue": "DownloadFileButton", "layout": { "colSpan": 1, "rowSpan": 1, "column": 11, "row": 0 } }, "parentName": "Taba317b6dcTabLabelGridLayout3826b978", "propertyName": "items", "index": 1 }, { "operation": "insert", "name": "DownloadFileButton2", "values": { "itemType": 5, "imageConfig": { "bindTo": "Resources.Images.FilesImage" }, "click": { "bindTo": "downloadFile" //pass parameter }, "visible": true "enabled": { "bindTo": "UsrClaveBajaTemprana" }, //Button Tooltip "hint": { "bindTo": "Resources.Strings.MensajeTooltipDownload" }, "markerValue": "DownloadFileButton2", "layout": { "colSpan": 1, "rowSpan": 1, "column": 11, "row": 1 } }, "parentName": "Taba317b6dcTabLabelGridLayout3826b978", "propertyName": "items", "index": 1 }, //method methods: { //method with parameter downloadFile: function(parameter) { var p = parameter; if (p == "A") //do some thing else //do some thing }
I appreciated your help!
King Regards!
Ezequiel Gómez
Like
Dear Ezaquiel,
The code you've provided above will work in case you add the appropriate Set parameter to UsrClaveAltaTemprana and UsrClaveBajaTemprana.
We suggest you to add the virtual attribute ,though. You can find the example of the attribute in various schemas in the configuration.
Lisa
Hello,
I have exactly the same request, but I don't understand the answer.
Can you explain this in a little more detail?
How can i pass a parameter to the downloadFile
"click": {
"bindTo": "downloadFile"
}
Hi Oliver, how are you? Below an script example. Let me know if it work for you:
{
"operation": "insert",
"name": "downloadTest",
"values": {
"itemType": 5,
"imageConfig": {
"bindTo": "Resources.Images.IconoDescargar"
},
"click": {
"bindTo": "downloadTest"
},
"visible": {
"bindTo": "UsrdownloadTest"
},
"hint": {
"bindTo": "Resources.Strings.MensajeTooltipDownload"
},
"layout": {
"colSpan": 1,
"rowSpan": 1,
"column": 18,
"row": 6
}
},
"parentName": "Tabe14d1848TabLabelGridLayout4868277b",
"propertyName": "items",
"index": 25
}
//////////////////////**////////////////////////////////////////
downloadTest: function() {
var esqEmpDocument = this.Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "UsrEmployeeDocument"
});
esqEmpDocument.addColumn("Id", "IdDocumento");
esqEmpDocument.addColumn("Name", "NombreDocumento");
//Filtro por Empleado
var filtroEmpleado = esqEmpDocument.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrEmpleado.Id", this.get("Id"));
//Filtro por Id de empleado
var filtroTipoDoc = esqEmpDocument.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrCodDocumento", "MA");
//Agrego filtros a la consulta
esqEmpDocument.filters.add("filtroEmpleado", filtroEmpleado);
esqEmpDocument.filters.add("filtroTipoDoc", filtroTipoDoc);
esqEmpDocument.getEntityCollection(function(result) {
if (result.success) {
result.collection.collection.items.forEach(this.descargar);
}
}, this);
},
descargar: function(item) {
var idDoc = item.values.IdDocumento;
var nombreDoc = item.values.NombreDocumento;
//this.showInformationDialog(idDoc);
var link = "../rest/FileService/GetFile/" + "90e79bf7-1c3e-467b-aaf2-9f8cdb376ce9" + "/" + idDoc;
var file = document.createElement("a");
file.href = link;
file.download = nombreDoc;// + ".pdf";
document.body.appendChild(file);
file.click();
document.body.removeChild(file);
},
Hello, thank you for your answer!
I can't see where you pass the parameter to "downloadFile".
I don't need to know how to download a file. I want to know how to pass a parameter to a function when I click on a button.