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
Former Member
0 Likes

First of all, you should use SearchFiled (for UI and UX reasons) instead of the Input.

SearchField supports two events:

  • search -> the query value is inside the query parameter
  • liveChange -> the query value is inside the newValue parameter

after that event you can filter your binding. Your code seems fine, can you show us the query result or can you create a jsbin?

naotoxxx
Participant
0 Likes

the result of my odata service?

Former Member
0 Likes

If you open the chrome developer tool you can see the network call. I need to know the query parameter (if you filter function is applying Filter correctly).