Skip to Content

Separate OData into two tables based on a criterial

Hi,

I wanted to separate oData coming from 1 entity set into two tables. The Active table would need to show only the ones with the end date of 20180312 and the Future table would show the rest.

I was trying to use the Filter and Filter operator but it still shows all the entries.

Currently I bind it like this:

var activeTemplate = new sap.m.ColumnListItem({
	cells: [
		new sap.m.Text({
				text: "{USER_ID}"
				}),
		new sap.m.Text({
				text: "{USER_LASTNAME}, {USER_FIRSTNAME}"
				}),
		new sap.m.Text({
				text: "{START_DATE} - {END_DATE}"
			})
				]
			});
var date = "20180312";
var oFilterActive = new Filter("END_DATE", FilterOperator.EQ, date);
activeTable.bindItems({
	path: "/ITS_OQASet",
	filter: oFilterActive,
	template: activeTemplate});
			
var date1 = "20180530";
var oFilterFuture = new Filter("END_DATE", FilterOperator.EQ, date1);
futureTable.bindItems({
	path: "/ITS_OQASet",
	filter: oFilterFuture,
	template: activeTemplate});

Thanks!

tables.png (20.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 15 at 10:07 PM

    Hi Elena,

    Have you implemented filter option in backend yet?

    Regards,

    Tri

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Tri Minh Le,

      I did end up adding the filter on the xml side like this:

      <Table id="activeTable" width="auto" class="sapUiResponsiveMargin activeTable" items="{path: '/ITS_OQASet', sorter: { path: 'START_DATE', descending: false}, filters : [{path: 'USER_ID', operator: 'EQ', value1: ''}]}" noDataText="No Data" busyIndicatorDelay="{worklistView>/tableBusyDelay}" growing="true" growingScrollToLoad="true" headerText="Active" mode="Delete" delete="deleteRowConfirm" updateFinished="onUpdateFinished" backgroundDesign="Solid">
      
      
      	<Table id="futureTable" width="auto" class="sapUiResponsiveMargin futureTable" noDataText="No Data" headerText="Future" items="{path: '/ITS_OQASet', sorter: { path: 'START_DATE', descending: false}, filters : [{path: 'FUTURE', operator: 'EQ', value1: 'X'}]}" growing="true" growingScrollToLoad="true" mode="Delete" delete="deleteRowConfirm" updateFinished="onUpdateFinished1">

      Then I was able to filter in the backend to where it only got the specific ones I wanted based on the date.