Code Monkey home page Code Monkey logo

vaibhavmojidra / sap-ui5---demo-filtering-using-searchfield Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 57 KB

In SAP UI5, you can implement filtering using a SearchField control to allow users to search and filter data in a list or table. The SearchField control provides an input field where users can enter search terms, and you can use the entered value to filter the data accordingly.

Home Page: https://vaibhavmojidra.github.io/site/

License: MIT License

JavaScript 58.00% HTML 42.00%
javascript javascript-es6 mojidra sap sap-ui5 ui5 vaibhav vaibhav-mojidra vaibhavmojidra

sap-ui5---demo-filtering-using-searchfield's Introduction

SAP UI5 Demo Filtering Using SearchField

In SAP UI5, you can implement filtering using a SearchField control to allow users to search and filter data in a list or table. The SearchField control provides an input field where users can enter search terms, and you can use the entered value to filter the data accordingly.

Code Explaination

Refer to /webapp/view/InvoicesList.view.xml

It contains a List control that displays a list of invoices. The list is bound to the Invoices model. The headerToolbar of the list contains a Toolbar control with a Title control and a SearchField control. The Title control displays the text "Invoices". The SearchField control is used to filter the list based on the user's input. The width property of the SearchField control is set to 50%. The search event of the SearchField control is bound to the onSearchSetFilter method of the controller. The items aggregation of the List control contains an ObjectListItem control that displays the product name and quantity of each invoice item.

Refer to /webapp/controller/InvoicesList.controller.js

The controller has a single method called onSearchSetFilter, which is called when the user enters a search query in the SearchField control of the view. The method first creates an empty array called aFilter. It then retrieves the search query entered by the user using the getParameter method of the oEvent object. If the search query is not empty, the method creates a new Filter object that filters the ProductName property of the Invoices model based on the search query using the FilterOperator.Contains operator. The Filter object is then added to the aFilter array.

Finally, the method retrieves the List control with the ID invoicesList using the byId method of the controller. It then retrieves the binding of the items aggregation of the List control using the getBinding method. The filter method of the binding is then called with the aFilter array as the argument to filter the list based on the user's search query.


Vaibhav Mojidra - 1.jpeg

Vaibhav Mojidra - 2.jpeg

sap-ui5---demo-filtering-using-searchfield's People

Contributors

vaibhavmojidra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.