cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lmheimendinger
Resolver II
Resolver II

Setting items in a gallery for icon or buton click

I have a gallery whose items have a quantity field from a SP list.  I want users to be able to select the value in that field as a default or else enter a new quantity.  I added another field, "QTYNEW" in the list as well.

 

On the gallery, I display QUANTITY but have a text input whose default is QTYNEW.  As it should the text input is blank.  I also added a button in the gallery (so it appears on each line) that I want make the text input field set to from the QUANTITY field when the button is selected.  I tried thsese for ONSELECT:

 

gallery.selected.textinput = text(gallery.selected.quantity)

 

gallery.selected.textinput=text(thisitem.quantity)

 

I also added a label and tried those expressions to set its text.  When I click the button, nothing seems to happen.

 

However, if I change the ONSELECT to SET(varname, text(thisitem.quantity)  and add a label with varname as its text value, it works.

 

The problem with that is that i need the text input field for each row in the gallery to be distinct, so I cannot use one variable.  What happens on any row is separate and distinct from the others.

 

Would using an array solve this problem?  Meaning that for each row, an item in the array would get the desired value.  But then i have another problem:  ROWS DO NOT HAVE TO BE PROCESSED IN ORDER, OR PROCESSED AT ALL!

 

Greatly appreciate any suggestions.

 

Oh, one more issue: when a row's value for this is set, I want to fill the row with a different color that persists. 

6 REPLIES 6
v-albai-msft
Microsoft
Microsoft

Hi @lmheimendinger ,

Do you want to populate the Textinput for selected item when its button be clicked? And leave other items (not selected) blank? Like below?

v-albai-msft_0-1618219449142.png

If yes, as you mentioned, variable will make all rows have a same value (I also tried some other methods, but cannot achieve this requirement) .

So I would suggest you try Patch function. By default, "QTYNEW" in the list is blank(without any value). When button clicked, the selected item’s QTYNEW will be update. Formula like below:

v-albai-msft_1-1618219449146.png

 

v-albai-msft_2-1618219449149.png

 

Besides, if you don’t want to update your SP list, you can create a collection based on this list using “Clearcollect(test1,listname)”, then use this collection in your gallery and also update this collection each time.

 

For your second question, you can set TemplateFill property of Gallery based on ThisItem.QTYNEW. Formula like this:

If(!IsBlank(ThisItem.QTYNEW),Red,White)

v-albai-msft_3-1618219449152.png

Best regards,

Allen

Thanks for the suggestions.  PATCH may be easier, and I do want an "undo" button for each item, so that would just require a reversal PATCH, too.   I still find it a shortcoming that you cannot set an individual item in a single line of another item in a gallery.  I am not understanding why technically this isn't a thing....

 

On the row color, I use TempplateFill to indicate the selected row:  If(ThisItem.IsSelected,LightYellow,White) so I don't want to lose that capability.  Would it work to use nested IFs so to look at whether QTYNEW !ISBLANK first and set the color to say red but follow with second IF as above ?  Play time I guess.

 

Thanks.

Well thought I had this but it didn't work.  

 

Onselect for button :  

Patch('Sales Orders Line Items',ThisItem, {'QTY Picked':ThisItem.Quantity} ); Refresh('Sales Orders Line Items')

 

Got no errors, but the list 'Sales Orders Line Items' column Qty Picked did NOT update, and of course the text input field where that is the default value did not change either.  I can see SOMETHING is happening as the ant dots momentarily appear across the screen.  I also refreshed list view but Qty Picked still didn't show as updated.   Here is a work in progress look at the gallery.....  When I click on button, the text input field (tan) should have the same value as the Quantity field above it.

 

picked_detail.jpg

Well I must be mistaken.  The PATCH worked and the Qty Picked was updated but it does not appear in the text input field until I exit that screen and re-enter the screen again.

 

I also did a RESET on the text input field instead of a REFRESH on the data source.  Didn't work.

Hi @lmheimendinger ,

1. Does your gallery directly use the SP list as data source? Or a collection?  

If it directly uses your SP list and your SP list update successfully, Refresh('Sales Orders Line Items') should work. This did work on my side.

2. You can try below formula to set the color. This time, no matter other conditions,  just IsSelected, the color will be LightYellow. 

If(IsBlank(ThisItem.mode)&&ThisItem.IsSelected=false,White,ThisItem.IsSelected=true,LightYellow,!IsBlank(ThisItem.mode),Red)

Best regards,

Allen

Hi @lmheimendinger ,

How are things going? Is my reply helpful to your issue?

I am willing to hear from you.

Best regards,

Allen

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (38,161)