0

I'm using this library https://l-lin.github.io/angular-datatables/#/welcome

I'm placing input fields inside of the table data like so:

  <td> <input type="text" ng-model="item.tiersk" /> </td>

However, when I do this I am no longer able to filter by order using the built in table head filter feature. I have other table data in other columns that work like so:

                    <td> {{item.expensetype.expensename}}</td>

Is there away to add a value to the td element to sort on? Maybe something like this:

<td value="{{item.tiersk}}"> <input type="text" ng-model="item.tiersk" /> </td>

2 Answers 2

0

Angular just reflects the array of data that's there. The best way to sort based on an input is to use a setter

i.e.
set myfield(s: string){
this.myarray[x].myfield = s;
this.sort(myarray)
}

Where x can be set by picking the row on the UI. (click)=pickRow() function.

Sign up to request clarification or add additional context in comments.

Comments

0

Is there away to add a value to the td element to sort on?

Yes, see HTML5 data-* attributes - cell data. Add a data-sort attribute to your <td>'s :

<td data-sort="{{item.tiersk}}"> <input type="text" ng-model="item.tiersk" /> </td>

Use data-sort for special values when the tables is sorted, i.e user clicking on column headers; data-filter for the search box.

Comments

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.