cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BillKern
Helper III
Helper III

Gallery search bar causing unexpected effects

Hello,

I am creating a work order app with an item grid displaying every item available to order. Within the grid are 3 text input boxes (quantity, price, ounce size) and a button to clear the fields. There is a search bar above the gallery that filters the gallery by stock number or description. 

Here is my gallery's items code:

 

 

 

SortByColumns(
    Filter(Order, ItemSearch.Text in Description ||  ItemSearch.Text in Text(Title)), "Title")

 

 

 

 

I'm having 2 problems with this setup that I'm hoping someone can help me with. 

 

 

1. I have the clear fields button set to only be visible if the quantity text box is not blank. I have this in my "Visible" property:

 

 

 

If(!IsBlank(Quantity), true, false)

 

 

 

This works perfectly fine when I first open the app. But when I type anything into the search bar the button appears on every item. I also have a TemplateFill property of the gallery with If(!IsBlank(Quantity), LightGreen, Transparent), and that is also behaving in the same way as the button. 

 

 

2. This one is the much bigger problem. If I have entered vales into any input box, and then use the search to find a new item, the fields that I entered previously are cleared out. 

 

Any thoughts?

 

 

UPDATE:

I also tried changing the Items property of the gallery to use a search function instead of filter, I started with just searching by description to test it:

Search(Order, ItemSearch.Text, "Description")

This is behaving the exact same way as before. 

1 ACCEPTED SOLUTION

Accepted Solutions

@v-bofeng-msft Good morning! 

 

I actually solved both of my problems with one solution. 

 

Users are able to enter values into the input boxes in the gallery, then once they click on the search bar I have the OnSelect property set to patch that data to the collection. 

ForAll(
    ItemGrid.AllItems,
    If(
        Value(Quantity.Text) > 0,
        Patch(
            Order,
            LookUp(
                Order,
                Value(StockNbr.Text) = Value(Title)
            ),
            {
                OrdQty: Value(Quantity.Text),
                OrdPrice: Value(Price.Text),
                OrdOz: Value(Oz.Text),
                Updated: true,
                OnHand: Value(QtyAvail.Text)
            }
        )
    )
);

 

This solved problem 1, because the default property for the input boxes displays the text inputted or if the collection is >0 it displays what is in the collection. So when the gallery is filtered the data isn't erased.

 

The Visible property for the X was kept as 

If(Value(Quantity.Text) > 0, true, false)

But for some reason after the items are patched it works as I intended. 

View solution in original post

8 REPLIES 8
eka24
Super User
Super User

Is quantity a name of a Textbox or a column. 

Try

If(!IsBlank(QuantityTextbox), true, false)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

It is the name of the text input box. I'm getting an error saying "Name isn't valid. This identifier isn't recognized" when I try QuantityTextbox

Please click on the Textbox you have named as Quantity and take a screenshot.

You are to replace the QuantityTextbox with that name. If you are not sure just Post the screenshot

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Alex_10
Super User
Super User

if you use text input and Quantity is the name of that control:
If(!IsBlank(Quantity.Text), true, false)

BillKern_0-1596554696054.png

Here's a screenshot. The gallery starts off white with no X's, If I search for an item (in this case #7007) and enter a quantity, then I clear the search terms, the whole grid turns green and shows X's at every item. 

@Alex_10 That did it, I was missing the .Text. Thank you!

 

Never mind, when I search an item, add a quantity, and then clear the search all items are still green with X's

Hi @BillKern :

Q1:Never mind, when I search an item, add a quantity, and then clear the search all items are still green with X's

The key is that the control has a default value.

Solution1:

Please set the Quantity's "Visible" property to:

 

Quantity.Text<>"Quantity"

 

Solution2:

1\Clear the Default property of the Quantity

2\Set the Quantity's "Visible" property to:

 

!IsBlank(Quantity.Text)

 

Q2: If I have entered vales into any input box, and then use the search to find a new item, the fields that I entered previously are cleared out.

Do you want users to clear the search box after the first search, and then search on the first search results when searching with new keywords?

I did not understand what you mean, could you explain it in detail?

Best Regards,

Bof

 

@v-bofeng-msft Good morning! 

 

I actually solved both of my problems with one solution. 

 

Users are able to enter values into the input boxes in the gallery, then once they click on the search bar I have the OnSelect property set to patch that data to the collection. 

ForAll(
    ItemGrid.AllItems,
    If(
        Value(Quantity.Text) > 0,
        Patch(
            Order,
            LookUp(
                Order,
                Value(StockNbr.Text) = Value(Title)
            ),
            {
                OrdQty: Value(Quantity.Text),
                OrdPrice: Value(Price.Text),
                OrdOz: Value(Oz.Text),
                Updated: true,
                OnHand: Value(QtyAvail.Text)
            }
        )
    )
);

 

This solved problem 1, because the default property for the input boxes displays the text inputted or if the collection is >0 it displays what is in the collection. So when the gallery is filtered the data isn't erased.

 

The Visible property for the X was kept as 

If(Value(Quantity.Text) > 0, true, false)

But for some reason after the items are patched it works as I intended. 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,834)