Skip to Content
0

Filter OData SAPUI5

Nov 22, 2016 at 04:09 PM

279

avatar image

Hello!

I have one question. I would like to filter my table with this list. Can I do it? And how can I this filter make?

This is a photo what I mean. The value is "Abteilung".

I want to choose "Abteilung" from list and get only rows with this "Abteilung".

Thank you in advance for your help!

tablel.png

tablel.png (74.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Sergio Guerrero Nov 22, 2016 at 04:21 PM
0

Khristina,

have you tried any code ? usually, you would get the table/list binding and then apply the filter to it.

here is a similar example:

https://sapui5.hana.ondemand.com/explored.html#/sample/sap.ui.table.sample.Filtering/preview

Share
10 |10000 characters needed characters left characters exceeded
Khristina Filonchik Nov 23, 2016 at 09:20 AM
0

Yes, I have already a table. I have tried to make a search field. I have a connecton between OData and my table. In metadata file Data is searchable. That's why I don't understand why it doesn't work.

Actually I want only to know how to make a connecton between this Filter List und my Table (please look on the photo below) ? I want that this list could be as Filter for my table

Maybe you can give me also some advices about search field. It doesn't work..

This is my code of filter...

  <EntityContainer Name="UI5UNI_SRV" m:IsDefaultEntityContainer="true">
                <EntitySet
                    xmlns:sap="http://www.sap.com/Protocols/SAPData" Name="Sat50Collection" EntityType="UI5UNI_SRV.KernIppsat50" sap:searchable="true" sap:content-version="1"/>
                </EntityContainer>
                <atom:link
                    xmlns:atom="http://www.w3.org/2005/Atom" rel="self" href="./kernc/UI5UNI_SRV/$metadata"/>
                    <atom:link
	onSearch : function (oEvt) {
 
			// add filter for search
			var aFilters = [];
			var sQuery = oEvt.getSource().getValue();
			if (sQuery && sQuery.length > 0) {
				var filter = new Filter("ZzStat", sap.ui.model.FilterOperator.Contains, sQuery);
				aFilters.push(filter);
			}
 
			// update list binding
		
			var list = this.getView().byId("idSatColl");
			var binding = list.getBinding("items");
			binding.filter(aFilters);
		},



tablel.png (74.7 kB)
Share
10 |10000 characters needed characters left characters exceeded
Daniel Degraf
Nov 23, 2016 at 10:29 AM
0

What is the error message you get when executing onSearch in the console?
Did you add the path sap.ui.model.Filter to the top of your controller file? Otherwise you have to change the Filter constructor to:

var filter = new sap.ui.model.Filter("ZzStat", sap.ui.model.FilterOperator.Contains, sQuery);
Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi!

There no problem in console. If I write something in search field, $batch shows "everything is ok"...maybe connectoin between table not right...

c.png (120.0 kB)
0

It's hard to debug issues remotely - I will try to ask you some questions, to check where the error might come from:

- Did you set a breakpoint in the function "onSearch" using the Chrome Debugger? Did it stop?

- I assume that it does stop, as you told us that it creates batch requests. But better get sure. Could you send us a screenshot of the batch request url?

- Could you please send me a screenshot of one entity from your odata service (so I can see the attribute names). Are you sure that you set the filter on the right attribute?
- Could you please double check the table id? Just to get sure that you bind the filter to the right table.

Thanks

Daniel

0

Hello again:)

So, yes I set a breakpoint, actually nothing happend.

If I begin to write a letter, this $batch begin also to react. it seems that requests only in backend happend...Maybe there are problem with OData.

Batch request URL..

Id of table should be right.

	<Table id="idSatColl" items="{ path: '/Sat50Collection' }" mode="SingleSelectMaster" selectionChange="showvalue" inset="false" fixedLayout="false" class="sapUiSizeCompact">
								<headerToolbar>
									<Toolbar>
										<ToolbarSpacer/>
									<Button tooltip="Infobar" text="Infobar" icon="sap-icon://message-information" press="handleSideContentShow"/>	<Button tooltip="Gesamt" text="Gesamt" icon="sap-icon://overview-chart" press="getGesamtView"/><Button tooltip="Nutzungsgrad" text="Nutzungsgrad" icon="sap-icon://switch-views" press="getViewNutzungsgrad"/><Button tooltip="Verweildauer" text="Verweildauer" icon="sap-icon://detail-view" press="getViewVerweildauer"/><Button tooltip="View Settings" icon="sap-icon://settings" press="handleViewSettingsDialogButtonPressed"/>
									</Toolbar>
								</headerToolbar>
								<columns>
									<Column id="__column1" hAlign="Center" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Klinik" id="__label3"/>
										</header>
									</Column>
									<Column id="__column2" hAlign="Center" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Abteilung" id="__label4"/>
										</header>
									</Column>
									<Column id="__column3" hAlign="Center" popinDisplay="Inline" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Station" id="__label5"/>
										</header>
									</Column>
									<Column id="__column4" visible="false" hAlign="Center" width="auto" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Afgbett.15" id="__label6"/>
										</header>
									</Column>
									<Column id="__column5" visible="false" hAlign="Center" width="auto" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Afgbett.14" id="__label7"/>
										</header>
									</Column>
									<Column id="__column6" visible="false" hAlign="Center" width="auto" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Afgbett.15" id="__label8"/>
										</header>
									</Column>
									<Column id="__column7" hAlign="Center" visible="false" width="auto" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header width="auto">
											<Label text="Afgbett.14" id="__label9"/>
										</header>
									</Column>
									<Column id="__column8" hAlign="Center" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Beleg.15" id="__label10"/>
										</header>
									</Column>
									<Column id="__column9" hAlign="Center" popinDisplay="Block" minScreenWidth="Tablet" demandPopin="true">
										<header>
											<Label text="Beleg.14" id="__label11"/>
										</header>
									</Column>

sea1.png (190.1 kB)
sea3.png (243.5 kB)
sea4.png (218.9 kB)
sea5.png (181.5 kB)
0
Deepak Anumula Nov 26, 2016 at 10:19 AM
0

Hello,

Please have a look at this Filters.

Note: Please consider the first Combo Box.


Thanks,

Deepak Raj.

,

Hello Khristina Filonchik,

Please have a look at this filters

hop u will get the required solution.

Note:Please consider the first drop down


Thanks,

Deepak Raj.

Share
10 |10000 characters needed characters left characters exceeded
Deepak Anumula Nov 26, 2016 at 10:19 AM
0

Hello,

Please have a look at this Filters.

Note: Please consider the first Combo Box.


Thanks,

Deepak Raj.

Share
10 |10000 characters needed characters left characters exceeded