0

https://github.com/swimlane/ngx-datatable/blob/master/demo/sorting/sorting-client.component.ts

in ngx-datatable, the datatable can be sorted with a click on the header column, however, I want to do some inline edit on the row and return the values with something like

edit($event, rowIndex, cellName)

The rowIndex return the sorted index, which is not matched with the original input rows (array), how to get a sorted array from the datatable?

1
  • The question could also be solved if the table return the unsorted index, but seems no way out Commented Aug 26, 2017 at 2:25

1 Answer 1

3

UPDATED

$$index not working on 10.1.0 ngx-datatable version

<ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
    {{rows.indexOf(row)}}.{{value}}
</ng-template>

is the only way i guess


Check for documentation:

Each row is decorated with a $$index attribute. This allows us to track the actual index of the row. This is needed because if you are lazy loading data into the grid the index upon which the data is loaded might not always be the 'actual' index its inserted.

This is also leveraged by the virtual scroll so it knows how to offset the row in the page's view port.

<ng-template ngx-datatable-cell-template let-row="row" let-value="value">
    {{row.$$index}}.{{value}}
</ng-template>
Sign up to request clarification or add additional context in comments.

4 Comments

How i can retrieve the $$index? Is it equivalent to let-rowIndex="rowIndex"? I have come across with this explanation but couldnt find any example
I have updated answer, but it seems that it is not working according to documentation =(
I guess it was equivalent to let-rowIndex="rowIndex" in previous versions
thanks Aleksandr, it works, I wonder if ngx offers a get method to retrieve the edited array? or it is a pure dom manipulation without a internal scope to handle the input array?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.