on 2019 Oct 09 7:37 AM
Hi Experts,
I need to understand if liveChange can be applied to multiple fields. When I tried this I am able to see some failure cases means search works but gives wrong filter data. In case of single field filter it works fine. I am sharing both the code here. Please check if you have faced similar issue in the past. If I used expression binding then search is not working.
XML Code :
<subHeader id="sub">
<Toolbar>
<ToolbarSpacer/>
<SearchField liveChange="onSearch" width="40%"/>
</Toolbar>
</subHeader>
<content>
<Table id="idTable" items="{/results}">
<columns>
<Column hAlign="Left">
<Text text="Employee Name" ></Text>
</Column>
<Column hAlign="Center">
<Text text="Employee ID"></Text>
</Column>
<Column hAlign="Center">
<Text text="S code"></Text>
</Column>
<Column hAlign="Left">
<Text text="S code Description"></Text>
</Column>
<Column hAlign="Left">
<Text text="Team Lead ID"></Text>
</Column>
<Column hAlign="Left">
<Text text="Status"></Text>
</Column>
<Column hAlign="Left">
<Text text="Functional Area"></Text>
</Column>
</columns>
<items>
<ColumnListItem type="Active">
<cells>
<Text text="{EMPLOYEE_NAME}"></Text>
<Text text="{EMPLOYEE_ID}"></Text>
<Text text="{S_CODE}"></Text>
<Text text="{S_CODE_DSCRIPTN}"></Text>
<Text text="{TEAMLEAD_ID}"></Text>
<Text text="{=${path:'FLAG'}==='Y'?Approved:${path:'FLAG'}==='N'?Rejected:''}"></Text>
<Text text="{FUNCTIONALAREA}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
Controller code :
single search code:
onSearch: function (oEvent) {
// var that = this;
// var sQuery = oEvent.getSource().getValue();
// var aFilter=[];
// if(sQuery && sQuery.length>0){
// aFilter.push(new sap.ui.model.Filter("FLAG",sap.ui.model.FilterOperator.Contains,sQuery));
// }else{
// return;
// }
// that.byId("idTable").getBinding("items").filter(aFilter);
// }
Multi field search code :
onSearch: function (oEvent) {
var that = this;
var sQuery = oEvent.getSource().getValue();
// filter container
var oFilter = new Filter({
// two filters
filters: [
new Filter("S_CODE", FilterOperator.Contains, sQuery), // filter for value 1
new Filter("EMPLOYEE_ID", FilterOperator.Contains, sQuery),
new Filter("FUNCTIONALAREA", FilterOperator.Contains, sQuery),
new Filter("TEAMLEAD_ID", FilterOperator.Contains, sQuery),
new Filter("FLAG", FilterOperator.Contains, sQuery)
]
});
var oBinding = that.byId("idTable").getBinding("items");
// apply filters
oBinding.filter(oFilter, FilterType.Application);
}
Json format data:
{
"results": [{
"EMPLOYEE_NAME": "Ravi",
"EMPLOYEE_ID": "0001",
"S_CODE": "ZE16",
"S_CODE_DSCRIPTN": "Data browser",
"FLAG": "Y",
"FUNCTIONALAREA": "MM",
"TEAMLEAD_ID": "SOX_TSTLED1",
},
"EMPLOYEE_NAME": "Ravi",
"EMPLOYEE_ID": "0001",
"S_CODE": "ZE16",
"S_CODE_DSCRIPTN": "Data browser",
"FLAG": "Y",
"FUNCTIONALAREA": "MM",
"TEAMLEAD_ID": "Lead1",
},
"EMPLOYEE_NAME": "Ram",
"EMPLOYEE_ID": "0001",
"S_CODE": "SE11",
"S_CODE_DSCRIPTN": "Data browser",
"FLAG": "N",
"FUNCTIONALAREA": "AA",
"TEAMLEAD_ID": "Lead2",
},
"EMPLOYEE_NAME": "Ramesh",
"EMPLOYEE_ID": "0001",
"S_CODE": "SE80",
"S_CODE_DSCRIPTN": "Data browser",
"FLAG": "",
"FUNCTIONALAREA": SD
"TEAMLEAD_ID": "Lead3",
}]
Prepare at least more than 20 data and then try to apply and let me know if you have any suggestion for my questions mentioned in the beginning.
Thanks and Regards,
RK
User | Count |
---|---|
82 | |
12 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.