Dynamic jquery table sort
I am Using http://tablesorter.com/docs/example-options-headers.html
$("#sort-table").tablesorter(
{headers: {
0: {
sorter: false
},
dynamic_value: {
sorter: false
}
}
});
How Can pass Dynamic_value for example from $('.header').length ?
<thead>
<tr>
<th width="20"><?php echo $check;?></th>
<th class="header">FullName</th>
<th class="header">Rank</th>
<th class="header">Email</th>
<th class="header">Position</th>
<开发者_如何学JAVAth width="15"></th>
</tr>
I suppose you want to apply sorter: false
to a certain column of which the number has to be calculated dynamically. As far as I know, JavaScript doesn't allow any direct syntax for that, so you'll have to go with the following:
headerset = {
0: {
sorter: false
}
// any other static column here
};
// repeat the following line for each dynamic value
headerset[dynamicvalue] = { sorter: false };
// the variable headerset now contains the header settings
// you can apply them to the tablesorter
$("#sort-table").tablesorter({ headers: headerset });
It's not elegant, but it should work.
Solution for above query is as below:
$(document).ready(function()
{
// extend the default setting to always sort on the first column
$.tablesorter.defaults.sortList = [[0,0]];
var newheader={
1:{sorter:false},
4:{sorter:false}
};
$(".tablesorter").tablesorter({headers:newheader});
});
We can also extends options using json string as shown here. I have created a bin with the solution on http://codebins.com/codes/home/4ldqpcd
精彩评论