Kanban Swimlane Foreign Key

Hi,


I need to have a ForeignKey relationship in the KanbanSwimlaneSettings so I can extract the string value for the header of the swim lane.


Something like this:


public List Alerts;

public List AlertLevels;

public class AlertEvent

{

public int AlertLevel;

}


public class AlertLevel

{

public int AlertLevelID;

public string Name;

}

// Where AlertLevel in class "AlertEvent" is a ForeignKey to AlertLevelID in class "AlertLevel"


<SfKanban TValue="AlertEvent" DataSource=@Alerts >

    <KanbanSwimlaneSettings KeyField=@nameof(AlertEvent.AlertLevel) KeyForeignField=@nameof(AlertLevel.AlertLevelID)       KeyForeignValue=@nameof(AlertLevel.Name) ForeignDataSource=@AlertLevels  EnableFrozenRows="true" />

</SfKanban>


Currently, Kanban does not have support for Foreign Key relationships. Is there a way around this?


Thank you,

Kenney


3 Replies

GK Gunasekar Kuppusamy Syncfusion Team September 24, 2021 03:26 AM UTC

Hi Kenney,

Currently we are validating you reported query from our end. We will update further details within two business days on or before 28th September.

Regards,
Gunasekar



KP Kenney Phan September 28, 2021 04:31 PM UTC

Hi Gunasekar,


Were you able to validate this query?


Thanks,

Kenney



GK Gunasekar Kuppusamy Syncfusion Team September 28, 2021 04:55 PM UTC

Hi Kenny.

Thanks for the patience.

We have further validated your reported requirement from our end.

By current Kanban behavior, Swimlane does not support the Foreign key field. Alternatively, we suggest that you, combine the two DataSource lists and assign it to the Kanban DataSource property.

We have prepared a sample for your reference. In this sample we have done the following things
  • Task1 and Tasks2 is the difference lists. Id in the Tasks1Model is the foreign key of StatusId in the Tasks2Model.
  • On OnInitialized method, we have merged the lists and assigned to the Kanban DataSource property.
Code snippets:
<SfKanban @ref="kanbanObj"  TValue="TasksModel" KeyField="Status" DataSource="@DataSource">
    <KanbanEvents TValue="TasksModel" ></KanbanEvents>
    <KanbanColumns>
        <KanbanColumn HeaderText="Backlog" KeyField="@(new List<string>() {"Open"})"></KanbanColumn>
        <KanbanColumn HeaderText="In Progress" KeyField="@(new List<string>() {"InProgress"})"></KanbanColumn>
        <KanbanColumn HeaderText="Testing" KeyField="@(new List<string>() {"Testing"})"></KanbanColumn>
        <KanbanColumn HeaderText="Done" KeyField="@(new List<string>() {"Close"})"></KanbanColumn>
    </KanbanColumns>
    <KanbanCardSettings HeaderField="Id" ContentField="Summary"></KanbanCardSettings>
    <KanbanSwimlaneSettings KeyField="Assignee" TextField="Assignee" SortDirection="SortDirection.Ascending"></KanbanSwimlaneSettings>
</SfKanban>

@code {

    SfKanban<TasksModel> kanbanObj;
    public List<TasksModel> DataSource = new List<TasksModel>() { };
    public class TasksModel
    {
        public int Id { getset; }
        public string Title { getset; }
        public string Status { getset; }
        public int TaskId { getset; }
        public string Summary { getset; }
        public string Assignee { getset; }

    }

    public void OnSorting(SwimlaneSortEventArgs args)
    {
       args.SwimlaneRows = args.SwimlaneRows.OrderBy(a =>
       DateTime.Parse(a.KeyField)).ToList();
    }

    public class Tasks1Model
    {
        public int Id { getset; }
        public string Status { getset; }
    }
    public class Tasks2Model
    {
        public int Id { getset; }
        public int StatusId { getset; }
        public string Assignee { getset; }
        public string Summary { getset; }
    }

    public List<TasksModel> cards;


    protected override void OnInitialized()
    {
        var cards = Tasks1.GroupJoin(Tasks2,
         c => c.Id,
         b => b.StatusId,
         (c, b) => new TasksModel
         {
             Id = c.Id,
             Status = c.Status,
             Assignee = b.Select(x => x.Assignee).FirstOrDefault(),
             Summary = b.Select(x => x.Summary).FirstOrDefault()
         });


        List<TasksModel> selectedCollection = cards.ToList();
        DataSource = selectedCollection;
    }
    public List<Tasks1Model> Tasks1 = new List<Tasks1Model>()
    {
        new Tasks1Model { Id = 1,  Status = "Open" },
        new Tasks1Model { Id = 2 Status = "Open" },
        new Tasks1Model { Id = 3,  Status = "Testing" },
        new Tasks1Model { Id = 4,  Status = "Testing" },
        new Tasks1Model { Id = 5,  Status = "Testing" },
    };
    public List<Tasks2Model> Tasks2 = new List<Tasks2Model>()
    {
        new Tasks2Model { Id = 11StatusId = 1, Summary = "Open summary", Assignee= "Andrew" },
        new Tasks2Model { Id = 12, StatusId = 2, Summary = "Open a card", Assignee= "Andrew" },
        new Tasks2Model { Id = 13StatusId = 3, Summary = "Open a card", Assignee= "Andrew" },
        new Tasks2Model { Id = 14StatusId = 4, Summary = "Open a card", Assignee= "Nancy" },
        new Tasks2Model { Id = 15StatusId = 5, Summary = "Open a card", Assignee= "Nancy" },
    };
}

Samplehttps://www.syncfusion.com/downloads/support/forum/169065/ze/Card-1356423100

Please check the sample and let us know if you have any concerns.

Regards,
Gunasekar


Loader.
Up arrow icon