I have a mobile app, that has an entity (database) stored on local storage. I already have a page, to output the database. My question is, how would I add a search bar, to filter the results of the database?

Hi,

  1. Create a local parameter called SearchInput
  2. Add an input widget to your screen and bind it to the SearchInput parameter
  3. In your aggregate that fetches the data from the local storage entity define your filter like
    entity.attribute like  "%" + SearchInput + "%"
  4. On the input widget define on the OnChange event a new screen action
  5. In that screen action perform a refresh of your aggregate

This is a basic search implementation

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi,

  1. Create a local parameter called SearchInput
  2. Add an input widget to your screen and bind it to the SearchInput parameter
  3. In your aggregate that fetches the data from the local storage entity define your filter like
    entity.attribute like  "%" + SearchInput + "%"
  4. On the input widget define on the OnChange event a new screen action
  5. In that screen action perform a refresh of your aggregate

This is a basic search implementation

Regards,

Daniel

Am also trying same search bar in Movies. 

Created one local variable like: Search Input. assign to that variable to Input widget.

After,

In the Database 

1. adding the filter

2. after am assign the Text Like:- Movie.Title = SearchInput.

Error:

 Can't indetify 'SearchInput' element in expression.

Question:

How to add a Filter& how to add expression.

Regards,

Prince


You proably missed step 1 or made spelling error, you have to add a local variable on your screen called SearchInput

Hi Fleming Zackery and Prince Raj,

There are detailed steps on how to do exactly this on the Sidebar exercise of the Mobile online training. It's using a Sidebar pattern to hide the filtering UI, but apart from that, basically works like Daniël has described.

I recommend you review that exercise (and the remainder of the online training) as that will make you a lot more effective developers.

Hope this helps

Daniël Kuhlmann wrote:

You proably missed step 1 or made spelling error, you have to add a local variable on your screen called SearchInput

I have added SearchInput local variable also assigned to my textfield,

After this in filter I have added below line but its not detecting my veriable, if instead of veriable I put hard code value then it's getting filtered.

SyntaxEditor Code Snippet

Movie.Title like "%"+SearchInput+"%"


Hi please share a screen print where I can see the peparation and the aggregate filter, you are doing something wrong that probably is easy to point at when shared by screenshot

Daniël Kuhlmann wrote:

Hi please share a screen print where I can see the peparation and the aggregate filter, you are doing something wrong that probably is easy to point at when shared by screenshot


PFA

Am I correct to see you have the aggregate of one screen, but the local variable defined on another screen?

Daniël Kuhlmann wrote:

Am I correct to see you have the aggregate of one screen, but the local variable defined on another screen?



Prince Raj wrote:

Daniël Kuhlmann wrote:

Am I correct to see you have the aggregate of one screen, but the local variable defined on another screen?