How can I dynamically create Syncfusion Ui's KanbanComponent and set Kanban Component header in ReactJS using TypeScript?

huangapple go评论90阅读模式
英文:

How can I dynamically create Syncfusion Ui's KanbanComponent and set Kanban Component header in ReactJS using TypeScript?

问题

以下是您要翻译的内容:

如何在React js中动态创建syncfusion Ui的KanbanComponent,并动态设置Kanban组件的标题?

<ColumnsDirective>
    <ColumnDirective headerText="Active" keyField="Active" allowToggle={true} template={this.columnTemplate} />
    <ColumnDirective headerText="Work In Progress" keyField="workInProgress" allowToggle={true} template={this.columnTemplate} />
    <ColumnDirective headerText="Approved" keyField="Approved" allowToggle={true} template={this.columnTemplate} />
    <ColumnDirective headerText="Closed" keyField="Closed" allowToggle={true} template={this.columnTemplate} />
    <ColumnDirective headerText="Archive" keyField="Archive" allowToggle={true} template={this.columnTemplate} />
</ColumnsDirective>
<KanbanComponent
    dialogOpen={this.dialogOpen.bind(this)}
    id="kanban"
    cssClass="kanban-overview"
    keyField="T_Status"
    dataSource={this.getFilteredData()}
    dragStop={(data: any) => {
        this.props.onTasksStatusChanged(data);
    }}
    enableTooltip={true}
    swimlaneSettings={{ keyField: "P_ProjectEngineer", allowDragAndDrop: true }}
    cardSettings={{
        headerField: "T_Title",
        template: this.renderCardTemplate.bind(this),
        selectionType: "Multiple"
    }}
    cardRendered={(props: any) => this.cardRenderer(props)}>
    <ColumnsDirective>
        {this.props.columnName.map((e: any) => {
            return <ColumnDirective headerText={e} keyField={e} allowToggle={true} template={this.columnTemplate} />;
        })}
    </ColumnsDirective>
</KanbanComponent>
英文:

How to create syncfution Ui's KanbanComponent Dynamically in React js and also how to set Kanban Component header Dynamically?

&lt;ColumnsDirective&gt;
                                        &lt;ColumnDirective headerText=&quot;Active&quot; keyField=&quot;Active&quot; allowToggle={true} template={this.columnTemplate} /&gt;
                                        &lt;ColumnDirective headerText=&quot;Work In Progress&quot; keyField=&quot;workInProgress&quot; allowToggle={true} template={this.columnTemplate} /&gt;
                                        &lt;ColumnDirective headerText=&quot;Approved&quot; keyField=&quot;Approved&quot; allowToggle={true} template={this.columnTemplate} /&gt;
                                        &lt;ColumnDirective headerText=&quot;Closed&quot; keyField=&quot;Closed&quot; allowToggle={true} template={this.columnTemplate} /&gt;
                                        &lt;ColumnDirective headerText=&quot;Archive&quot; keyField=&quot;Archive&quot; allowToggle={true} template={this.columnTemplate} /&gt;
                                    &lt;/ColumnsDirective&gt;
 &lt;KanbanComponent
                   dialogOpen={this.dialogOpen.bind(this)}
                                    id=&quot;kanban&quot;
                                    cssClass=&quot;kanban-overview&quot;
                                    keyField=&quot;T_Status&quot;
                                    dataSource={this.getFilteredData()}
                                    dragStop={(data: any) =&gt; {
                                        this.props.onTasksStatusChanged(data);
                                    }}
                                    enableTooltip={true}
                                    swimlaneSettings={{ keyField: &quot;P_ProjectEngineer&quot;, allowDragAndDrop: true }}
                                    cardSettings={{
                                        headerField: &quot;T_Title&quot;,
                                        template: this.renderCardTemplate.bind(this),
                                        selectionType: &quot;Multiple&quot;
                                    }}
                                    //dialogSettings={{ fields: fields as any }}
                                    cardRendered={(props: any) =&gt; this.cardRenderer(props)}&gt;
                                     &lt;ColumnsDirective&gt;
                                        {this.props.columnName.map((e: any) =&gt; {
                                            return &lt;ColumnDirective headerText={e} keyField={e} allowToggle={true} template={this.columnTemplate} /&gt;
                                        })}
                                    &lt;/ColumnsDirective&gt;
                                &lt;/KanbanComponent&gt;

答案1

得分: 0

以下是翻译好的部分:

如果您想动态设置看板组件的标题,您可以使用看板的"columns"属性。请查看以下代码和示例,

代码片段:

<KanbanComponent
    id="kanban"
    cssClass="kanban-overview"
    keyField="Status"
    dataSource={data}
    enableTooltip={true}
    swimlaneSettings={{ keyField: 'Assignee' }}
    cardSettings={{
        headerField: 'Title',
        template: cardTemplate.bind(this),
        selectionType: 'Multiple',
    }}
    dialogSettings={{ fields: fields }}
    cardRendered={cardRendered.bind(this)}
    columns={columns}
>
</KanbanComponent>

列设置:

let columns= [
{
  headerText: 'To Do',
  keyField: 'Open',
  allowToggle: true,
},
{
  headerText: 'In Progress',
  keyField: 'InProgress',
  allowToggle: true,
},
{
  headerText: 'In Review',
  keyField: 'Review',
  allowToggle: true,
},
{
  headerText: 'Done',
  keyField: 'Close',
  allowToggle: true,
},
],

示例: https://stackblitz.com/edit/react-pjv7rd?file=index.js

API 链接: https://helpej2.syncfusion.com/react/documentation/api/kanban#columns

谢谢,

Vinitha

英文:

If you want to set Kanban component header dynamically, you can use the columns property of the Kanban. Check the code and sample below,

Code snippet:

 &lt;KanbanComponent
        id=&quot;kanban&quot;
        cssClass=&quot;kanban-overview&quot;
        keyField=&quot;Status&quot;
        dataSource={data}
        enableTooltip={true}
        swimlaneSettings={{ keyField: &#39;Assignee&#39; }}
        cardSettings={{
          headerField: &#39;Title&#39;,
          template: cardTemplate.bind(this),
          selectionType: &#39;Multiple&#39;,
        }}
        dialogSettings={{ fields: fields }}
        cardRendered={cardRendered.bind(this)}
        columns={columns}
      &gt;         
        
      &lt;/KanbanComponent&gt;

let columns= [
{
  headerText: &#39;To Do&#39;,
  keyField: &#39;Open&#39;,
  allowToggle: true,
},
{
  headerText: &#39;In Progress&#39;,
  keyField: &#39;InProgress&#39;,
  allowToggle: true,
},
{
  headerText: &#39;In Review&#39;,
  keyField: &#39;Review&#39;,
  allowToggle: true,
},
{
  headerText: &#39;Done&#39;,
  keyField: &#39;Close&#39;,
  allowToggle: true,
},

],

Sample: https://stackblitz.com/edit/react-pjv7rd?file=index.js

API Link: https://helpej2.syncfusion.com/react/documentation/api/kanban#columns

Regards,

Vinitha

huangapple
  • 本文由 发表于 2023年5月26日 14:40:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76338227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定