@Michael E. Gernaey Thanks so much for the detailed response. I put the code snippet into the editor and modified the post. Here is some more detail on this app. I think your idea is on the right track. My wording about moving items in and out of the collection was not quite correct. The collection items are remaining the same, but a column in the collection changes from a ZoneID (will explain later) of Date|Time to "Unassigned" or the reverse of that.
am using a custom control built by Scott Durow called DragDrop (
GitHub - scottdurow/power-drag-drop), which allows dragging and dropping of items from a "zone" to another "zone" on the screen. When the items are "dropped," the code then modifies the collection by changing the ZoneID column to either "Unassigned" (dragged into the original list on the right) or a ZoneID (a combination of Date|Time).
Even though the number of items in the collection is not actually changing during this action, I have used the monitor function, and for every item/row in the Collection, the SortbyColumns and Filter action is repeated. They take from 1 to 5 milliseconds each, so it adds up.
A screenshot of the app is shown below. Zone setup is fairly complex, with three different dragdrop zone components, nested containers and galleries.
Overall, this works as expected, but I am trying to make the experience better for the end user, so they do not experience a significant delay after the drag/drop of an item. I do have filters at the top where they can search the items and select from the dropdowns. This typically reduces the number of visible items to one or two, after which the drag/drop is almost instantaneous.
The code that occurs after an item is dragged/dropped is shown below. This part runs fast, since it is only dealing with the single item that is being dragged and dropped. The filtering and re-sorting takes some time.
//This works, but slow, takes up to 5 or 6 seconds for larger loads
Set(varCountMovedZone, CountRows(Filter(ListTasksDrop.CurrentItems, HasMovedZone = true)));
ForAll(
Filter(ListTasksDrop.CurrentItems, HasMovedZone = true) As TaskAssignment,
Patch(AheadWithDates, //was Patch(AheadWithDates,
LookUp(AheadWithDates, LoadNumText = TaskAssignment.ItemId), //previously LdTaskId = TaskAssignment.ItemId, but no matches in AheadWithDates
With(
{
StartDate: dtpStartDate.SelectedDate,
ZoneData: Split(TaskAssignment.DropZoneId, "|"),
Unassigned: TaskAssignment.DropZoneId = "unassigned",
SeqNo: LookUp(SeqDates, RowDate = DateValue(First(Split(TaskAssignment.DropZoneId, "|")).Value)),
varReqDate: If(TaskAssignment.DropZoneId = "unassigned", Blank(), DateAdd(dtpStartDate.SelectedDate, LookUp(SeqDates, RowDate = DateValue(First(Split(TaskAssignment.
DropZoneId, "|")).Value)).Sequence -1, TimeUnit.Days) + TimeValue(LookUp(colqtrTime, Time =
(Last(Split(TaskAssignment.DropZoneId, "|")).Value), Time))),
varDateOnly: If(TaskAssignment.DropZoneId = "unassigned", Blank(), DateAdd(dtpStartDate.SelectedDate, LookUp(SeqDates, RowDate = DateValue(First(Split(TaskAssignment.
DropZoneId, "|")).Value)).Sequence -1, TimeUnit.Days))
},
{
Zone: TaskAssignment.DropZoneId,
Edited: true,//sets edited to true so only edited loads will be saved to Dataverse
UserRqDate: Now(),
/*try variabbles from above instead of code
ReqDate: If(Unassigned, Blank(), DateAdd(StartDate, SeqNo.Sequence -1, TimeUnit.Days) + TimeValue(LookUp(colqtrTime, Time =
(Last(ZoneData).Value), Time))),
DelivDate: If(Unassigned, Blank(), DateAdd(StartDate, SeqNo.Sequence -1, TimeUnit.Days) + TimeValue(LookUp(colqtrTime, Time =
(Last(ZoneData).Value), Time))),
ReqDateOnly: If(Unassigned, Blank(), DateAdd(StartDate, SeqNo.Sequence -1, TimeUnit.Days)),
*/
ReqDate: varReqDate,
DelivDate: varReqDate,
ReqDateOnly: varDateOnly,
ReqDateSort: varReqDate,
ReReq: "No"//for any movement of loads, ReReq is set back to "No"
}
)//end of With
)//end of patch
); //end of ForAll