web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Keep textboxes persist...
Power Apps
Answered

Keep textboxes persistent on filtered gallery items

(0) ShareShare
ReportReport
Posted on by 204

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?

 

Categories:
  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @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."

  • agneum Profile Picture
    204 on at

    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?

     

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @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."

     

  • agneum Profile Picture
    204 on at

    @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).

     

     

  • mdevaney Profile Picture
    29,993 Moderator on at

    @agneum 

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard