swati
swati

Reputation: 2139

How to move the rows of the table in java script based on the data

I am new to javascript/jquery. I apologize if my question is very basic. I have a table in java script with headers like

Element price gain
 xyz     10   20
 abc     29   10

the value of the gain is coming from the back and it is keep on changing the value. Now my question is when ever the value changes then the table should automatically sorted. The rows of the table should move automatically Lets say in the above example the gain for the abc is "30" which came from the back end then the table should change automatically .The table should look like this now

Element price gain
abc      29   30
xyz      10   20

So here the rows shuffled based on the data. How can we achieve this thing in javascript /jquery

I would really appreciate if some one can give any ides how to do.

Thanks, Swati

Upvotes: 0

Views: 168

Answers (1)

2ndkauboy
2ndkauboy

Reputation: 9377

I guess that you update the table through a AJAX call as you cannot "pull" an update easily to the table. So why not creating the whole table on the backend and sort it there and than update the whole table. On a very large table that is even faster than parsing the complete table and update only some rows or cells.

Upvotes: 1

Related Questions