Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #113100
    michaelsanders
    Participant

    Can I use Smart Kanban with a REST API?

    #113117
    Markov
    Keymaster

    Hi,

    You can look at it:

    
    <smart-kanban
      #kanban
      [dataSource]="data"
      [columns]="columns"
      (cardUpdate)="onTaskUpdate($event)">
    </smart-kanban>
    
    import { Component, OnInit, ViewChild } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    
    @Component({
      selector: 'app-kanban',
      templateUrl: './kanban.component.html'
    })
    export class KanbanComponent implements OnInit {
      @ViewChild('kanban', { static: false }) kanban: any;
    
      data: any[] = [];
      columns = [
        { dataField: 'todo', label: 'To Do' },
        { dataField: 'inProgress', label: 'In Progress' },
        { dataField: 'done', label: 'Done' }
      ];
    
      constructor(private http: HttpClient) {}
    
      ngOnInit() {
        this.loadData();
      }
    
      loadData() {
        this.http.get<any[]>('https://api.example.com/tasks').subscribe((tasks) => {
          this.data = tasks;
        });
      }
    
      onTaskUpdate(event: CustomEvent) {
        const { card, oldColumn, newColumn } = event.detail;
        this.http.patch(<code>https://api.example.com/tasks/${card.id}</code>, {
          status: newColumn.dataField
        }).subscribe();
      }
    }

    Best regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.