Home:ALL Converter>Primeng Datatable selection with weird data

Primeng Datatable selection with weird data

Ask Time:2017-05-23T18:52:37         Author:Milan_w

Json Formatter

I'm retrieving two sets of data from an MSSQL server. Set one: (which is user specific, so this set changes)

[
  {
    "TargetID": 1,
    "Enabled": true
  },
  {
    "TargetID": 2,
    "Enabled": true
  }
]

Set two:

[
  {
    "Platform": "BB",
    "ID": 1
  },
  {
    "Platform": "MDL01",
    "ID": 2
  },
  {
    "Platform": "MDLEX",
    "ID": 4
  }
]

Set two populates the Primeng Datatable. Set one's TargetID value refers to the ID in set two. Whenever the TargetID value is the same as the ID in set two, I have to check this in the Datatable.

The datatable:

<div class="col-md-12">
            <p-dataTable [value]="doelplatformen" [rows]="3" class="thumbnail" resizableColumns="true" [paginator]="true" [pageLinks]="0"
                [rowsPerPageOptions]="[3,5,10]" emptyMessage="Loading data" [(selection)]="selectedDoelplatformen" (onRowSelect)="onRowSelectDoelplatform($event)">
                <p-column [style]="{'width':'30px'}" selectionMode="multiple"></p-column>
                <p-column [style]="{'width':'40px'}" field="ID" header="ID"></p-column>
                <p-column field="Platform" header="Platform"></p-column>
            </p-dataTable>
        </div>

I haven't tried much because I have no idea how this could be achieved? I can't even figure out how to hard code the selected rows...

Any help would be greatly apreciated! Thanks in advance!

Author:Milan_w,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44132765/primeng-datatable-selection-with-weird-data
yy