New Feature Request: Ability to "select" a row programmatically.
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior
Unable to programmatically “Select” a row. In order to perfom the “Select” operation, the user must click the row.
Expected behavior
Within the TS file, I’d like to perform a “Select” operation on a specific row, and have it “Open” the details of that row. I would like to be able to SAVE the selected row parameter, perform an update of the underlying this.rows, and then reselect the previously selected rows.
Reproduction of the problem
What is the motivation / use case for changing the behavior?
In my application, the rows display summary data for multiple months worth of information. Upon selecting a row, it opens a detailed datatable, that shows projects and values for expanded for the same months. Within the details table, users can interact with the data and update values, which commit to the database. A refresh of the original data table data will force the detail view to close. I would like to keep it open (or at the very least be able to “reselect” the record that was open in the first place).
Please tell us about your environment:
Mac, Sublime/Ultra Edit, npm, node, etc.
- Table version: 0.8.x
11.0.2 is the current version I’m using, this is a new feature request not found in older versions.
- Angular version: 2.0.x
5.0.1
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
All
- Language: [all | TypeScript X.X | ES6/7 | ES5] all
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:16
Top GitHub Comments
The DatatableComponent object should allow you to do that.
Assume that you already have object
row
that you want to select it from ts file, and by using@ViewChild
query you able to obtain an instance of the table nameddatatable
In order to select the row from ts, do this:
In order to navigate to a page with specific selected row info, just use Angular router feature, like:
@edjm1971 Try look at the demo code to see how they are auto selecting the 3rd row on start. Instead of doing it on start you want to do it on map click event. https://github.com/swimlane/ngx-datatable/blob/master/src/app/selection/selection-single.component.ts
After you select the map, you need to find out which row in the table reflect the map select. And set the this.selected = [tabledata[rownumber]];
declare variable: selected = [];
My guess you have map click function(){ … // find rownumber where the data is in table this.selected = [tabledata[rownumber]]; //this should highlight your table. }
html: The import line is [selected]=“selected” which binds to selected variable. <ngx-datatable class=“material” [rows]=“rows” [columnMode]=“ColumnMode.force” [columns]=“columns” [headerHeight]=“50” [footerHeight]=“50” rowHeight=“auto” [selected]=“selected” [selectionType]=“SelectionType.single” (activate)=“onActivate($event)” (select)=“onSelect($event)”
Hope this helps.