Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jQuery tableSorter plugin with Angularjs

I'm trying to use the JQuery tablesorter plugin working along with Angular. Currently if you click on any column for sorting the entire width and structure of the table changes and a new row with the ng-repeat expressions is created.

$(document).ready(function() {
    $("#check").tablesorter();
});

 

<table id="check" class="table table-bordered table-striped table-condensed table-hover tablesorter" cellspacing="1">
    <thead>
        <tr>        
            <th class="header">Product Code#</th>
            <th class="header">Item Description#</th>
            <th class="header">Unit Cost#</th>
        </tr>
    </thead>
    <tbody>
        <tr ng:repeat="i in itemresponse" >
            <td><a href="#/ItemSearch/{{i._ItemID}}" >{{i._ItemID}}</a></td>
            <td>{{i.PrimaryInformation._ShortDescription}}</td>
            <td>{{i.PrimaryInformation._UnitCost}}</td>
        </tr>
    </tbody>
</table>
like image 581
Aki Avatar asked Nov 26 '12 12:11

Aki


2 Answers

You're doing it wrong.

If you want to sort rows in a table with AngularJS, you should use the orderBy filter. There is no need to include another framework. Once you have made that leap, you can find a plethora of samples online (or on SO).

See for example this fiddle: http://jsfiddle.net/uRPSL/1/

like image 56
iwein Avatar answered Oct 23 '22 19:10

iwein


Fortunately there's an Angular Module called ng-table.

like image 33
Dhaval Ptl Avatar answered Oct 23 '22 17:10

Dhaval Ptl