How to add a custom property in SfKanban Header?

Hello,

I have added a property called "estimated time" in the task entity. Is it possible to add all estimated time in a category of kanban and show in SfKanban header?

image

I looked in syncfusion doc (https://help.syncfusion.com/wpf/kanban-board/column), there are only 5 tags available for binding?

image

Thank you in advance for your answer


1 Reply 1 reply marked as answer

HM Hemalatha Marikumar Syncfusion Team December 21, 2020 04:24 PM UTC

     
Hi bala ilango, 
 
Greetings from Syncfusion.  
 
We would like to let you know that header template has data context of ColumnTag. It has only listed properties as per in the UG section. But we achieved it by passing the entire data context that is ColumnTag and itself has private field name of Column (it has entire cards collection as per the category).  
 
To achieve it, we have to add custom KanbanModel with including the EstimatedTime property to hold the int value. As per below code snippet with usage of converter, we can get the total count of estimated time of corresponding category, 
 
public class EstimatedCalConveter : IValueConverter 
    { 
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            var dataContext = (value as ColumnTag); 
            var total = 0; 
 
            if (dataContext != null) 
            { 
                PropertyInfo ColumnGetter = dataContext.GetType().GetProperty("Column", BindingFlags.NonPublic | BindingFlags.Instance); 
                KanbanColumn kanbanColumn = (KanbanColumn)ColumnGetter.GetValue(dataContext); 
                foreach(var KanbanCardItem in kanbanColumn.Cards) 
                { 
                    total = total + (KanbanCardItem.Content as CustomKanbanModel).EstimatedTime; 
                } 
            } 
 
            return "Estimated Time:  " + total + " mins"; 
        } 
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
        { 
            throw new NotImplementedException(); 
        } 
    } 
 
<syncfusion:SfKanban.ColumnHeaderTemplate> 
                <DataTemplate> 
                    <StackPanel Orientation="Vertical"  > 
                        <TextBlock Text="{Binding Header}" Margin="0,0,0,3" /> 
                        <TextBlock Text="{Binding  Converter={StaticResource EstimatedCalConveter}}"/> 
                    </StackPanel> 
                </DataTemplate> 
            </syncfusion:SfKanban.ColumnHeaderTemplate> 
 
 
Output: 
 
 
 
Regards,
Hemalatha M.
 


Marked as answer
Loader.
Up arrow icon