More filter in mgt-Tasks
Is there any way in which I can filter task and show only the tasks which are not completed yet, and show only tasks up to specific number. For e.g. if I want to show only top 10 task to user.
currently the mgt-tasks fetches all the task which eventually impact the application performance.
Hello kandari7, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
Hi @kandari7, you can create a filter function via the taskFilter property to control which tasks are shown by the component.
let taskView = document.querySelector('mgt-tasks');
taskView.taskFilter = task => task.appliedCategories.category3 === true;
However, this will still fetch all tasks and I agree this can impact the app performance. The bigger issue with the tasks component is that it fatches all tasks for all folders, not just for the current view. On top of that, all tasks are refreshed when a task is changed (ex: completed).
There are several optimizations we should do on the Task component to improve performance, by ensuring only the necessary tasks for the current view are loaded (lazy loading folders and pages), and only update the modified tasks.
@shweaver-MSFT, I wonder if this is work that is already covered by the work you are doing for #423?
@nmetulev, this is not covered by my upcoming changes. I'm doing a lot of refactoring, but not necessarily adding any new functionality. Adding a max-tasks or similar attribute would be a new feature.
Sorry, I was asking about optimizing how tasks are loaded and how the API is used, not about adding the max-tasks feature. I imagine for the split between planner and todo, you will need to rewrite this anyway?
It's a good time to do it, but not actually necessary for the split. The split out MGtTodo and MgtPlanner components are individually just as inefficient as the original 😅 I can look into it though. I've assigned myself to the issue so I don't forget.
Great!!! hope to see more feature on mgt task and other components as well as this is emerging.
Hi any update on this feature request? I tried following the filter function suggestion above but was unsuccessful.
This should work with taskFilter. Closing for now.
@sebastienlevert, could you send us an example explaining how to use taskFilter?
https://learn.microsoft.com/en-us/graph/toolkit/components/tasks#properties look at the end of this section.
Thank you Sebastien!