Splitbutton inside a datatable, callback function issue

UI Components for Angular
Post Reply
bdesrochers
Posts: 10
Joined: 02 Jan 2017, 22:46

25 Jan 2017, 16:43

Hello

I'm using datatable and one of my column has a customer template with a splitbutton inside it.

Code: Select all

<p-dataTable [value]="weekdata" [responsive]="true" [rows]="10" [paginator]="true">
          <p-column header="Title"  field="wee_title"></p-column>
          <p-column header="Start Date"  field="wee_startdate"></p-column>
          <p-column header="End Date"  field="wee_enddate"></p-column>
          <p-column header="Number"  field="wee_number"></p-column>
        <p-column header="Action" [style]="{'width':'154px','overflow':'visible'}" field="wee_id">
          <template let-item="rowData" pTemplate="body">
            <p-splitButton label="Edit" icon="fa-check" (onClick)="save()" [model]="items"></p-splitButton>
          </template>
        </p-column>
      </p-dataTable>
How can i pass my wee_id property of my row to one of the callback function within the menu of the splitbutton.

Code: Select all


  ngOnInit() {
    this.items = [
        {label: 'Copy', icon: 'fa-refresh', command: (event) => {
            console.log(event);
            this.copy();
        }},
        {label: 'Delete', icon: 'fa-close', command: (event) => {
            this.delete();
        }}
    ];

    this.getweekData();
  }



originalbeast
Posts: 2
Joined: 23 Feb 2017, 09:42

23 Feb 2017, 09:45

I have the same question. How can we pass values to the other splitbutton items?

originalbeast
Posts: 2
Joined: 23 Feb 2017, 09:42

23 Feb 2017, 09:47

I have the same question. How can you pass values to a splitbutton's item method?

raf
Posts: 1
Joined: 12 Jul 2018, 13:11

12 Jul 2018, 13:18

Write a function which takes a parameter (row specific information) and returns items array which is built in this function, so you have row specific information available while you build it. Then bind the function call to the splitbutton model, something like that: [model]="getItems(row)".

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: Seo-Ul-But and 8 guests