nstudio/nativescript-checkbox

ListView Checked Issue

Closed this issue · 3 comments

Hello, I'm trying to use the checkbox on a RadListView and I can't get the checkbox state to change for each individual list item. It's only working for the first item in the list view, but any other item won't cause
FirstCheckBox.nativeElement.checked property to change.

Here's my code:

HTML:

<ng-template let-item="item" let-i="index" let-odd="odd" let-even="even">
    <StackLayout>
      <GridLayout rows="90, auto, auto">
        <StackLayout rowSpan="2" backgroundColor="#BDBDBD"></StackLayout>
        <CheckBox #CB1 horizontalAlignment="Right" verticalAlignment="Top" (tap)="getCheckProp()" ></CheckBox>
        </StackLayout>
      </GridLayout>
    </StackLayout>
</ng-template>

Typescript:

 public getCheckProp() {
    console.log('checked prop value = ' + this.FirstCheckBox.nativeElement.checked);
  }

Hello, I found a way to make it work.

@horeyes Can you share your solution? please

You need to have a boolean property in your model. Then you use the index to change the property to true or false.

Let me know if you need more help.