a question about DataTableModule module

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
williamjieh
Posts: 5
Joined: 01 Jul 2017, 18:10

02 Aug 2017, 02:24

Hi,

I'm trying to use DataTableModule to show a list of data and when click one row , routing to a component to show the detail of this row.
I finished the data listing part. But stuck on showing detail part.
How should I detect the click event of one row in DataTableModule ?

The code from demo is like below:

Code: Select all

<div class="ui-g-12">
    <div class="card card-w-title">
      <h1>DataTable</h1>
      <p-dataTable [value]="cars1" selectionMode="single" [(selection)]="selectedCar" 
        [paginator]="true" [rows]="10" [responsive]="true">
        <p-header>List of Cars</p-header>
        <p-column field="vin" header="Vin" [sortable]="true"></p-column>
        <p-column field="year" header="Year" [sortable]="true"></p-column>
        <p-column field="brand" header="Brand" [sortable]="true"></p-column>
        <p-column field="color" header="Color" [sortable]="true"></p-column>
      </p-dataTable>
    </div>
  </div>
  
Thank you!

williamjieh
Posts: 5
Joined: 01 Jul 2017, 18:10

03 Aug 2017, 03:15

Figure it out.
In

Code: Select all

<p-dataTable>
element, add

Code: Select all

(click)="onSelect(selectedXXX)"
, and create

Code: Select all

onSelect
method in the your own listing component.

User avatar
DarthMaul
Posts: 582
Joined: 23 Nov 2015, 21:20

04 Aug 2017, 08:43

And you can also check this http://primefaces.org/primeng/#/datatable/selection selection with events section can be helpfull.

williamjieh
Posts: 5
Joined: 01 Jul 2017, 18:10

05 Aug 2017, 00:55

Thank you @DarthMaul

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

14 Aug 2017, 13:27

+1 ;)

Post Reply

Return to “Ultima - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests