cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Collection in DataTable

Hi,

 

I have a datatable with a collection as datasource. I also have a button that fires the Collect function so that i fill the collection with data. But why does not the datatable update? Does it only take a copy of the collection at start up and present that data? Now I have to restart the whole app for the datatable to show the new data...

 

Is there maybe a functon that can force the datatable to read from the collection again..?

6 REPLIES 6
Mike8
Level 10

Re: Collection in DataTable

Hello krigj,

Button1.OnSelect : Collect(Collection1,{ID:1,text:"A"})
DataTable1.Items : Collection1
I set the DataTable to display the ID and text.

Whenever I press the button I can see the added data on the DataTable.
What is different in your case? Is your collection nested?

Anonymous
Not applicable

Re: Collection in DataTable

@Mike8

I will show you my code on how I add data to my collecton. The Collection is not nested, and all data is added to the collection in the way i want.

 

//I am using this index collection so that i can use the ForAll as a normal for-loop ish with increasing index variable
Clear(IndexForDetails);
ForAll([1,2,3,4,5,6,7,8,9,10],If(Value <= CountRows(Split(ThisItem.Signhist,",")),Collect(IndexForDetails,Value)));

//Make the DetailTable as a Collection
Clear(DetailTable);
ForAll(IndexForDetails,
 Collect(DetailTable,{
     Event_Log: Last(FirstN(Split(ThisItem.Signhist,","),Value)).Result,

     Status: If(CountRows(Split(ThisItem.Statushist,","))>=Value,
     Last(FirstN(Split(ThisItem.Statushist,","),Value)).Result,
     "-"),

     Date: If(CountRows(Split(Substitute(ThisItem.Datehist,"&#58;",":"),","))>=Value,
     Last(FirstN(ForAll(Split(Substitute(ThisItem.Datehist,"&#58;",":"),","),Text(Result,"[$-en-US]dd.mm.yy hh:mm")),Value)).Value,
     "-"),

     Comment: If(CountRows(Split(Substitute(ThisItem.Comment_Mod_Hist,"&#58;",":"),"#"))>=Value,
     Last(FirstN(Split(Substitute(ThisItem.Comment_Mod_Hist,"&#58;",":"),"#"),Value)).Result,
     "-")
     }));

//The Datatable is placed on the GeneralDetailScreen Navigate(GeneralDetailScreen,ScreenTransition.Fade)

So as you can see I have different Strings of the same length with delimiter "," or "#" so the data saved in the String can be easy accesed. The Strings can contain different amount of values, therefore the if in the three last fields. 

 

But as I am saying, all the values is written to the collection, but does not show in the datatable.

 

In "Items"-field of the datatable i write "DetailTable" which is the name of the collection, and I can see that it takes the refrence to the collection.. I have also set the datatable to show all of the four fields; Event_Log, Status, Date and Comment

Mike8
Level 10

Re: Collection in DataTable

Hello,

Unfortunately I can't recreate what you are trying to do in order to test it. I don't have the ThisItem.etc values
If you try to use a gallery instead of a datatable? Do you have the same issue?

Anonymous
Not applicable

Re: Collection in DataTable

Tried it now, works perfect with a gallery! The ThisItem is a row in a SharePoint list btw. 

 

I will probably just use the gallery now then.. Thanks @Mike8

Community Support Team
Community Support Team

Re: Collection in DataTable

Hi @Anonymous,

 

I didn't create the collection in your way, but just a simple one:

 

ClearCollect(C,{Name:TextInput1.Text})

When I put "C" in the data table, and change the data in TextInput control, data table would change according to what I fill in TextInput control:

 

1.PNGCapture.PNG

 

Notice that, I need to first click on the button, and make the Name column created already, then add it to the data table:

Capture.PNG

 

Are you using DetailTable in the data table control? If so, please check if you have included the columns in DetailTable collection in data table. Also, check if these columns are still there after changing according to your formula.

 

I saw in your formula that create the DetailTable, there are "ThisItem.". Where did you put this formula? What did you get the value of "ThisItem."?

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Collection in DataTable

I ended up using a gallery instead...but I did all the things that you are showing here @v-monli-msft 

 

The columns where yet selected after I used the formula and the ThisItem is from a Gallary that holds data from a sharepoint list. As I have said all the data were saved to the Collection, but it would not update in my datatable. I needed to restart my app to see the changes everytime.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,668)