J’ai appris qu’en essayant d’utiliser le plug-in tableorter de jQuery, la table doit utiliser
et 1st 2nd 3rd 1st value 2nd value 3rd value 1st value 2nd value 3rd value 1st value 2nd value 3rd value 1st value 2nd value 3rd value
ça ressemble à ça mais sans les balises
Vous devriez jeter un coup d’oeil ici – Code Project Sortable Gridview utilisant JQuery Tablesorter
Pour l’essentiel, vous devez utiliser la propriété UseAccessibleHeader de Gridview afin qu’une balise thead soit sortie dans la sortie HTML.
protected void Page_Load(object sender, EventArgs e) { if (this.gridView.Rows.Count > 0) { gridView.UseAccessibleHeader = true; gridView.HeaderRow.TableSection = TableRowSection.TableHeader; gridView.FooterRow.TableSection = TableRowSection.TableFooter; } }
Si vous utilisez une table html avec l’atsortingbut runat = “server” au lieu des contrôles serveur asp.net, il semble qu’il n’existe pas de moyen simple d’empêcher les balises thead de ne pas s’afficher dans la sortie html. Vous pouvez utiliser JQuery pour insérer les balises thead dans le DOM dès la préparation du document.
//in script tags after JQuery and JQuery tablesorter src declarations $(function() { $('#test').prepend( $('').append($('#test tr:first').remove()) ); $("#test").tablesorter(); //your table options }); //your html and asp markup 1 2 3 my data 1.1 this data 1.2 that data 1.3 this data 2.1 that data 2.2 my data 2.3 that data 3.1 my data 3.2 this data 3.3
sort ce qui fonctionne correctement avec tablesorter-
1 2 3 this data 1.1 that data 1.2 my data 1.3 my data 2.1 this data 2.2 that data 2.3 that data 3.1 my data 3.2 this data 3.3
commence par ça …
print("heading1 heading2 content1 content2 content3 content4
");
alors fais ceci:
print("$(document).ready(){ $('table.turnMeIntoTableSort > tr:first').wrap(''); $('table.turnMeIntoTableSort > tr:gt(1)').wrapAll(''); //now draw the tablesorter $('table.turnMeIntoTableSort').tablesorter(); }");