Page 1 of 1

Retrieve Selected Row on Ionic Grid

Posted: Fri Dec 21, 2018 3:01 pm
by Pasteur Miranda

Hi,

I placed a series of texts on an ionic grid, retrieving these texts from a list via directive "ng-repeat" (item in list). Each row of this grid also contains a button. I want to click this button and get the row number where that button is located or the text that was placed on that line (placed there via ng-repeat).
That is: on row 1 I have text "Text 1 " that was placed by ng-repeat , in row 2 and 3 the same, etc. I'd like to click button on, for instance, row 3 and get the row number or the text "Text 3".
I tried this with the ng-selected directive but it did not work. Any idea?

Thanks a lot.


Retrieve Selected Row on Ionic Grid

Posted: Sat Dec 22, 2018 12:33 pm
by Serhii Kulibaba

Hello Pasteur,

You can use item's properties there or use it's index.

  1. If you need to get a number of the clicked item, please add to the property ng-repeat "track by $index", so it will be:
    preitem in items track by $index/pre
    Now you can use that $index value in the ng-click function, just pass it as a parameter: preng-click=myFun($index)/pre

  2. If you need to get the property "Text" of the item, you can pass it to the ng-click function, so it will be:
    preng-click=myFun(item.Text)/pre


Retrieve Selected Row on Ionic Grid

Posted: Sat Dec 22, 2018 5:32 pm
by Pasteur Miranda

Thank you very much, Sehrii, it worked perfectly!