0

I need to add checkbox in Angular 4 typescript we are using ng2-table.

//code for ng-table in html
<ng-table (tableChanged)="onChangeTable(config)"
(cellClicked)="onCellClick($event)"
[rows]="rows" [columns]="columns">
</ng-table>

//to create checkbox I am adding html in component where filling the data.
data.forEach((item: any) => 
{item.CheckBox = '<input type="checkbox"></input>';

//cell click event in table component is getting triggered
public onCellClick(data: any): any {
     this event is getting triggered
     ....
}
  1. Check box on UI is disabled or not able to checked. I think some event is getting triggered and reverting selected value to false each time. How to prevent that?
  2. Where do I bind this check box to ng-model or similar?

Please help. Thanks you.

Sushil Gupta
  • 97
  • 1
  • 12

1 Answers1

0

Where is your data binded to the table? Where is the template for the checkbox? Can you re-create your problem in a stackblitz repo?

By the way, there is a thread about checkboxes in the official repo issues

ForestG
  • 17,538
  • 14
  • 52
  • 86
  • Thanks for your reply. It is not regular check box. It is contained in ng2-table. I am able to trigger cell-click event. But check box is disabled from UI. Also going through the links you provided. – Sushil Gupta Apr 25 '18 at 15:43
  • Can you please provide a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve) please? In [stackblitz](https://stackblitz.com/) for instance. – ForestG Apr 25 '18 at 16:52
  • I have edited my question and added more details. If you can help. Thanks. – Sushil Gupta Apr 25 '18 at 20:38
  • Thanks for your reply. Problem is solved. In cellClick event we are able to add dynamic basic html code. Which has solved the problem. – Sushil Gupta May 02 '18 at 14:45