Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to sort table tbody on header click but except first in tbody.


My table is
HTML
<table>
    <thead>
        <tr>
            <th>
                Icon
            </th>
            <th>
                 Name
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
            </td>
            <td>
                <input type="text" placeholder="search"/>
            </td>
        </tr>
        <tr>     //want sort only this tr, data is from database
            <td>@item.Icon</td>
            <td>@item.Name</td>
        </tr>
    </tbody>
</table>
Posted
Comments
Sinisa Hajnal 3-Apr-15 2:29am    
You sort items in the model and controller decides what view will be returned. Make javascript method that calls controller method to sort the data and returns view with sorted data.

1 solution

Here you have jquery library to sort the html table by their headers.
 
Share this answer
 
Comments
Jayesh27j 3-Apr-15 2:26am    
i have tried sorttable.js also ,but it sorts all tbody
Solai Raja 3-Apr-15 2:28am    
not clear!
Jayesh27j 3-Apr-15 2:46am    
tried but not sorting yet
Solai Raja 3-Apr-15 2:48am    
better refer your Developer tool(Pressing f12 on browser) and Enable the Script to view the error caused by your script.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900