Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables Powerapps-库中的变量_Variables_Gallery_Powerapps - Fatal编程技术网

Variables Powerapps-库中的变量

Variables Powerapps-库中的变量,variables,gallery,powerapps,Variables,Gallery,Powerapps,我是powerapps新手,遇到了一个问题。我正在创建一个“购物车”,希望用户能够通过按下两个图标来添加或删除1 我尝试过使用一个变量,但当我按下绿色“+”时,它会将1添加到整个库中,而不仅仅是所选项目。如何隔离变量,使其仅在按下按钮的项目内运行?我希望它有意义。您不应该使用变量,而是使用集合。当用户按下+按钮时,收集()不存在的带有1个单位的项目,或将()当前单位更新为+1。与x按钮类似。 对于+按钮的OnSelect属性,类似如下所示: If( IsEmpty(Filter(MyCo

我是powerapps新手,遇到了一个问题。我正在创建一个“购物车”,希望用户能够通过按下两个图标来添加或删除1


我尝试过使用一个变量,但当我按下绿色“+”时,它会将1添加到整个库中,而不仅仅是所选项目。如何隔离变量,使其仅在按下按钮的项目内运行?我希望它有意义。

您不应该使用变量,而是使用集合。当用户按下+按钮时,收集()不存在的带有1个单位的项目,或将()当前单位更新为+1。与x按钮类似。 对于+按钮的OnSelect属性,类似如下所示:

If(
    IsEmpty(Filter(MyCollection, Id = ThisItem.Id)),
    Collect(MyCollection, {Id: ThisItem.Id, Quantity: 1}),
    UpdateIf(MyCollection, Id = ThisItem.Id, {Quantity: Quantity+1})
    )
要在库中显示的文本类似于:

LookUp(MyCollection, Id=ThisItem.Id, Quantity)
更像这样,;
如果(IsEmpty(Filter(MyCollection,FoodID=Gallery.Selected.FoodID)),collection(MyCollection,{FoodID:Gallery.Selected.FoodID,Quantity:1}),UpdateIf(MyCollection,FoodID=Gallery.Selected.FoodID,{Quantity:Quantity+1}),我个人会使用一个集合

用户想要添加的每个项目都可以单击+图标,它会将该项目添加到集合中

收集(购物清单,{Items here})

然后我会将收藏链接到图库,在图库中添加删除图标和编辑图标。您可能需要使用Clear(ShoppingList)删除所有内容,这将清除收藏

一旦用户满意,他们可以单击“签出”,这将把集合保存到sharepoint列表或您选择的数据库中


要将收藏添加到数据库,请将按钮设置为OnSelect=Collect(ShoppingList,DB name)

请设置答案中的代码格式?这将更容易阅读。