cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi i'm triying to filter my list but is not working, i tried with search fild, input an submit and not success this is my view:

	<App>
		<Page title="{i18n>titulo}">
			<content>
			<SplitContainer id="SplitContDemo" initialDetail="detail" initialMaster="master">
				<detailPages>
					<Page id="detail" title="Resultados" class="sapUiStdPage">
						<content>
						<SearchField width="auto" search="onSearch" class="sapUiTinyMargin" />
							<List  	   id="lista"
									   items="{ path: '/MaterialListSet',
												sorter: {
					      	  						path: 'MTYPE',
					      	  						descending: false,
					      	  						group: true
					      	  					}
									   }"
									   growing="true">
							<items>
									<ObjectListItem title="{MATERIAL}"
													type="Active"
													press=""
													number= "{MTYPE}"
													icon="sap-icon://database">
										<firstStatus>
											<ObjectStatus 	title="{ULT_MODIF}"/>
										</firstStatus>
										<secondStatus>
													<ObjectStatus
														title="{i18n>GrupoArt}"
														text="{GP_ART}"/>
										</secondStatus>
										<attributes>
											<ObjectAttribute text="{RESPONSABLE}" />
											<ObjectAttribute text="{SIZE}" />
										</attributes>
									</ObjectListItem>
								</items>
							</List>
						</content>
					</Page>
				</detailPages>
				
				<!-- Resultado -->
				<masterPages>
					<Page id="master" title="Buscar" icon="sap-icon://action" class="sapUiStdPage">
						<content>
					      		
					      		<Label text="Categoría" />
										<Input id="cat" value="" tooltip="Ejemplo: 11111 , 22222 , A4333" submit="onSearchs"/>
										<Toolbar>
										<ToolbarSpacer/>
											<Button icon="sap-icon://search" type="Default" press="onSearch"/>
										</Toolbar>
								
						</content>
					</Page>
				</masterPages>
			</SplitContainer>
				
			</content>
		</Page>	
	</App>

and this is my controller, check i have a fuction for each element, input, search field an submit

		onSearch : function(oEvt) {
			// build filter array
			var aFilter = [];
			// fetch event parameter
			var sQuery =  oEvt.getSource().getValue();
			
			if(sQuery && sQuery.length > 0) {
				var filter = new Filter("RESPONSABLE", sap.ui.model.FilterOperator.Contains, sQuery);
				aFilter.push(filter);
			}
			
			var list = this.getView().byId("lista");
			var binding = list.getBinding("items");
			binding.filter(aFilter, "Application");
		},
		onSearchs : function(oEvent) {
			// build filter array
			var aFilter = [];
			// fetch event parameter
			var sQuery = oEvent.getParameter("value");
			// Regresa la lista
			var oList = this.getView().byId("lista");
			// get binding for aggregation 'items'
			var oBinding = oList.getBinding("items");


			if (sQuery) {
				aFilter.push(new Filter("RESPONSABLE", FilterOperator.Contains, sQuery));
			}
			// apply filter. an empty filter array will show all items
			oBinding.filter(aFilter);
		},
		
		onSearch : function(oEvent) {
			// build filter array
			var aFilter = [];
			// fetch event parameter
			var sQuery = this.byId('cat').getValue();
			// Regresa la lista
			var oList = this.getView().byId("lista");
			// get binding for aggregation 'items'
			var oBinding = oList.getBinding("items");


			if (sQuery) {
				aFilter.push(new Filter("RESPONSABLE", FilterOperator.Contains, sQuery));
			}
			// apply filter. an empty filter array will show all items
			oBinding.filter(aFilter);
		}

"RESPONSABLE" it's the property of my entity of the odata , yes, in capital so, can you see something that i'm not ? and also i don't get any error

0 Likes
View Entire Topic
mvaibhav
Contributor
0 Likes

HI Naoto,

Is your service method reading the filter parameters passed to it and returning the correct data(filtered data) ?

Your backend service method should read the filters passed and return the filtered data to UI5.

Thanks,

Vaibhav Maheshwari