cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate IV
Advocate IV

Keep textboxes persistent on filtered gallery items

I have textboxes next to my items in the gallery where I can enter data. When I make a filter such that the items are updated, the data I wrote in the textboxes disappears.

How can I make the textboxes persistent?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Keep textboxes persistent on filtered gallery items

@agneum 

To keep them persistent you would need to update each record in your datasource with the new information typed in.

 

Put this code in the OnChange property of the Text Input.

Patch(
    your_datasource_name,
    ThisItem,
    {ColumnName1: TextInput1.Text}
)

 

Then make sure the Default property of the Text Input is updated to this.

ThisItem.ColumnName1

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

5 REPLIES 5
Highlighted
Super User
Super User

Re: Keep textboxes persistent on filtered gallery items

@agneum 

To keep them persistent you would need to update each record in your datasource with the new information typed in.

 

Put this code in the OnChange property of the Text Input.

Patch(
    your_datasource_name,
    ThisItem,
    {ColumnName1: TextInput1.Text}
)

 

Then make sure the Default property of the Text Input is updated to this.

ThisItem.ColumnName1

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Advocate IV
Advocate IV

Re: Keep textboxes persistent on filtered gallery items

My items are a datasource based off an SQL view. It doesn't have a column for quantity, it just gets the item information.

I use a seperate collection to store items that have non-zero values called SelectedItem. 
Can I patch to the collection?

 

 

Highlighted
Super User
Super User

Re: Keep textboxes persistent on filtered gallery items

@agneum 

How many columns does SelectedItem have?  I assume more than one.  In this code you are only collecting a single column.  You need to define the values for all the columns for collect to work.

 

{Qty: Qty.Text; AnotherField1: "Text", AnotherField2: 1000}

 

Another possibility is Quantity needs to be converted to a number.


{Qty: Value(Qty.Text)}

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Highlighted
Advocate IV
Advocate IV

Re: Keep textboxes persistent on filtered gallery items

@mdevaney 

I got it to work with the defaultvalue and patch functions. Thanks for your help!


For my Default for the input field I used:

 

LookUp( SelectedItem; ItemId = PRODUCTNUMBER; Qty ) //Identify the row and return its current Qty from the collection

 

 

And for the OnChange for the input field:

 

Patch(SelectedItem;{ItemId: ThisItem.PRODUCTNUMBER}; {ItemId: ThisItem.PRODUCTNUMBER; ItemName: ThisItem.PRODUCTNAME; Qty:Qty.Text})

//Return the record in the collction by ItemId and update it, otherwise it will be created

 



I tried using ThisItem as the second argument as your example suggested, but that gave the error that the function Patch had invalid arguments. I suspect this to be because ThisItem had more columns in it than my collection did. As my datasource wasn't the same as the source I was patching to, I had to specify the record by Id.

 

 

 

Patch(
    SelectedItem,
    ThisItem,
    {ItemId: ThisItem.PRODUCTNUMBER; ItemName: ThisItem.PRODUCTNAME; Qty:Qty.Text}
)

//Did not work for me

 

 


Simliarly setting

 

 

 

ThisItem.Qty

 

 


Didn't work either. I therefore had to find the record with the lookup function. But your post definately got me to the solution, thanks again!



TLDR: Patch function together with ThisItem only works if you are patching to the source the items are read from, or the column definitions match up. If you're patching to another source, specifiy the record by its unique Id (product number in my case).

 

 

Highlighted
Super User
Super User

Re: Keep textboxes persistent on filtered gallery items

@agneum 

I'm glad to hear you got it working.  Thanks for coming back to share your code!

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,238)