我有以下超鏈接網格視圖列需要由IncidentId數值排序。有沒有辦法將數據保存爲超鏈接,只能通過IncidentId進行排序?當我使用下面的JavaScript函數對它進行「數字」排序時,它會中斷並且列不會排序。如果我將sType聲明爲「string」或「html」,它會進行排序,但它將數據字母化而不是數字排序,換句話說,它會將其列爲93,82,71,40,123,122,121,而不是123,122,121,93,82,71,40。如何以數字方式對DataTable中的超鏈接進行排序?
<asp:HyperLinkField HeaderText="Incident ID:" DataNavigateUrlFields="IncidentId"
DataNavigateUrlFormatString="view.aspx?id={0}" DataTextField="IncidentId"/>
<script type="text/javascript">
$(function() {
$('#GridViewIncidents').dataTable({
"bFilter": false,
"bSort": true,
"aoColumnDefs": [{ "sType": "numerical", "aTargets": [0]}]
});
});
</script>
使用插件,也許:http://datatables.net/plug-ins/sorting – Blazemonger 2012-02-20 15:48:30
在Google上也發現了這個:http://datatables.net/forums/discussion/367/bug-sort-number-column -and-stype/p1 – Blazemonger 2012-02-20 15:49:10
我會看看論壇的討論。感謝這些鏈接。 – Chaser09 2012-02-20 16:23:32