on 2024 Aug 09 2:35 PM
Hello community! First of all, thank you very much for reading me. I'm having a problem that is surely very simple but I can't find the reason for what is happening. I have a ComboBox like this:
<ComboBox
items="{path:'/TipoAuditoria'}"
selectedKey="{filters>TiposDeAuditoria}"
selectionChange="onSubmitFilter"
enabled="{= !${viewModel>/hasUIChanges}}"
>
<items>
<core:Item key="{ID}" text="{DESCRIPCION}" />
</items>
</ComboBox>
In the controller my filtering logic is as follows:
onSubmitFilter: function (oEvent) {
const sValue = oEvent.getSource().getValue(); // Input value
const sKey = oEvent.getSource().getSelectedKey(); // ComboBox value
let oView = this.getView();
let oModel = oView.getModel("filters");
oModel.setProperty("/AuditoriaDescripcion", sValue);
oModel.setProperty("/TiposDeAuditoria", sKey);
// Filter logic
let sAuditoria = oModel.getProperty("/AuditoriaDescripcion");
let sTiposDeAuditoria = oModel.getProperty("/TiposDeAuditoria");
let aFilters = [];
if (sAuditoria) {
aFilters.push(new Filter("DESCRIPCION", FilterOperator.Contains, sAuditoria));
}
if (sTiposDeAuditoria) {
aFilters.push(new Filter("TIPOAUDITORIA_ID", FilterOperator.EQ, sTiposDeAuditoria));
}
this._oAuditoriaTable.getBinding("items").filter(aFilters);
}
Filtering doesn't work, the "getSelectedKey()" method doesn't seem to bring me any value. I don't know what mistake I'm making. I'm sharing the "filters" model just in case:
_loadFilters: function () {
const oViewModelFilters = new JSONModel({
AuditoriaDescripcion: "",
TiposDeAuditoria: ""
});
this.getView().setModel(oViewModelFilters, "filters");
}
I appreciate the help, I need this to finish my view. Thanks!
Hello,
Maybe here's the problem...
selectedKey="{filters>TiposDeAuditoria}"
path should be preceded by "/"
selectedKey="{filters>/TiposDeAuditoria}"
Regards,
Radoslaw
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
11 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.