0
votes

My app contains a list of products carried by a chain of retail stores. I want the manager of each store to be able to select their store number on the home page and then see the gallery list of only the products in their store.

On Screen1 I have dropdown1, which lists the store numbers and then there is Button1 which should be pressed to navigate to BrowseGallery1, filtered by the store number selected in the dropdown.

My data source is a CDS called Products. There is a text field called StoreNum which has the store numbers, such as "111", "115", etc.

I tried putting the following in the OnSelect of Button1:

Navigate(BrowseScreen1,ScreenTransition.Fade,{StoreNum: 
Dropdown1.Selected.Value}), but that didn't work. It navigates to the 
page, but doesn't filter by StoreNum.

After I figure out the filter situation, I want the search box on BrowseScreen1 to search a few fields in the gallery, but only for that particular store. I currently have this in the "Items" section of BrowseGallery1:

Sort(If(IsBlank(TextSearchBox1.Text), Products, Filter(Products, TextSearchBox1.Text in Text(ItemNameWeight))), ItemNameWeight, Ascending)

That seems to search my ItemNameWeight field ok, but with no regard to store number.

I'd appreciate some help!

Thanks, Tony

1

1 Answers

0
votes

When you pass a variable to a screen in the Navigate option, that everything it does, it just creates a variable in that screen for you to use, and you are not using it in the browse screen.

First of all let's rename the variable so it does not conflict with the column name:

Navigate(BrowseScreen1,ScreenTransition.Fade,{SelectedStore: Dropdown1.Selected.Value})

Now, lets update the function in the Items property for your gallery so it filters by StoreNum, like this:

Sort(Filter(If(IsBlank(TextSearchBox1.Text), Products, Filter(Products, TextSearchBox1.Text in Text(ItemNameWeight))), SelectedStore = StoreNum), ItemNameWeight, Ascending)

That should filter all the stores with the right number and then filter by the products in the search box.

If you want to search for further fields in the database, you can add more Filter commands. However I would recommend adding a new screen for each type of search, as that would simplify the Items function in your gallery.

Cheers.