swimlane / angular-data-table

A feature-rich but lightweight ES6 AngularJS Data Table crafted for large data sets!
http://swimlane.github.io/angular-data-table/
MIT License
577 stars 141 forks source link

how to set a row as selected programmatically #270

Open TanyaLi opened 7 years ago

TanyaLi commented 7 years ago

Hi, I'm using swimlane datatable in angular 2 ( with node.js), my datatable is like this:

<swui-datatable class='datatable material dark' id='dtMessage' [rows]='messages' [headerHeight]="0" [rowHeight]="'65px'" [externalPaging]="false" [limit]="10" [columnMode]="'flex'" [selectionType]="'single'">
<swui-datatable-column name="" [sortable]="false" [flexGrow]="3">

        </swui-datatable-column>
    </swui-datatable>

my page has a list in the left panel, and item details shown in the right panel. After click on delete button in the right panel, the current selected item is deleted, and then set the previous/next item in the list as selected by default and show its details in the right panel.

i've achieved all the features except not sure how to set an item in the list (datatable) as selected by code.

tried added something like this: [class.active]="row.messageId === currentSelectedMesId" to tag : but at this point, there is no 'row'.

please advise.

Regards & Thanks, Xiaohui Li.

TanyaLi commented 7 years ago

some html in the datatable were not being shown , template is used within the < swui-datatable-column > tag as : '< template let-row="row" swui-datatable-cell-template > ...'

JimmyKuruvilla commented 7 years ago

Hi Tanya,

I had the same need. This is a fork of the select codepen demo: http://codepen.io/anon/pen/dvVJgj

Adding a reference to the selected item into the selected array worked for me