2013-01-18 64 views
1

由於某些原因,當字段包含像%這樣的特殊字符時,排序完全失敗。Tablesorter不對字段進行排序%

這​​顯示列A如何正常工作,沒有百分比。

<tbody id="search_result"> 
    <tr> 
     <td>AAA 0</td> 
     <td>39.90</td> 
     <td>29 Dec 2012</td> 
    </tr> 
    <tr> 

但只要%進來失敗 - >fiddle

<tbody id="search_result"> 
    <tr> 
     <td>AAA 0%</td> 
     <td>39.90</td> 
     <td>29 Dec 2012</td> 
    </tr> 
    <tr> 

回答

2

見這個例子

$(function() { 

    $.extend($.tablesorter.themes.bootstrap, { 
    // these classes are added to the table. To see other table classes available, 
    // look here: http://twitter.github.com/bootstrap/base-css.html#tables 
    table  : 'table', 
    header  : 'bootstrap-header', // give the header a gradient background 
    footerRow : '', 
    footerCells: '', 
    icons  : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header 
    sortNone : 'bootstrap-icon-unsorted', 
    sortAsc : 'icon-chevron-up', 
    sortDesc : 'icon-chevron-down', 
    active  : '', // applied when column is sorted 
    hover  : '', // use custom css here - bootstrap class may not override it 
    filterRow : '', // filter row class 
    even  : '', // odd row zebra striping 
    odd  : '' // even row zebra striping 
    }); 

    // call the tablesorter plugin and apply the uitheme widget 
    $("#tab_open_deals").tablesorter({ 
    theme : "bootstrap", // this will 

    widthFixed: true, 

    headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon! 

    // widget code contained in the jquery.tablesorter.widgets.js file 
    // use the zebra stripe widget if you plan on hiding any rows (filter widget) 
    widgets : [ "uitheme", "filter", "zebra" ], 

    widgetOptions : { 
     // using the default zebra striping class name, so it actually isn't included in the theme variable above 
     // this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden 
     zebra : ["even", "odd"], 

     // reset filters button 
     filter_reset : ".reset", 

     // set the uitheme widget to use the bootstrap theme class names 
     // uitheme : "bootstrap" 

    } 
    }) 
    .tablesorterPager({ 

    // target the pager markup - see the HTML block below 
    container: $(".pager"), 

    // target the pager page select dropdown - choose a page 
    cssGoto : ".pagenum", 

    // remove rows from the table to speed up the sort of large tables. 
    // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. 
    removeRows: false, 

    // output string - default is '{page}/{totalPages}'; 
    // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} 
    output: '{startRow} - {endRow}/{filteredRows} ({totalRows})' 

    }); 

}); 

$(document).ready(function() { 


}); 

Example

問候

+0

+1非常感謝,它似乎在工作。部分解決方案是「0:{sorter:」text「},」但還有另一件事,我不知道你做了什麼。仍在調查。 – Houman

+1

@Kave,這就是你應該需要的......這是[你的演示更新](http://jsfiddle.net/Mottie/fEWdz/5/),和[這裏是MG_Bautista的演示](http:// jsfiddle。 net/Mottie/vCTHw/576 /)更新爲使用jQuery UI主題(這是一個較老的版本演示),它需要'headerTemplate'選項來包含一個'{icon}''。 – Mottie

+0

謝謝Mottie,非常感謝。它正在工作。 :) – Houman

相關問題