jQuery表排序器-无法获取要在表的列上排序的表(单元格值可以在排序前由jQuery动态更改)
我有一个行表,最后一个单元格是或否。该列不响应排序,可以在更改排序顺序之前进行修改,但不进行排序 我无法生成一个最小的完整的可验证示例,但我可以说,初始化代码只需简单到jQuery表排序器-无法获取要在表的列上排序的表(单元格值可以在排序前由jQuery动态更改),jquery,tablesorter,Jquery,Tablesorter,我有一个行表,最后一个单元格是或否。该列不响应排序,可以在更改排序顺序之前进行修改,但不进行排序 我无法生成一个最小的完整的可验证示例,但我可以说,初始化代码只需简单到 $(".tablesorter").tablesorter(); //this is inside a document.ready block 所有其他行都会排序,但不排序的那一行令人费解 这是零配置吗? 我还尝试将上述初始化调用链接到: $(".tablesorter").tabl
$(".tablesorter").tablesorter(); //this is inside a document.ready block
所有其他行都会排序,但不排序的那一行令人费解
这是零配置吗?
我还尝试将上述初始化调用链接到:
$(".tablesorter").tablesorter({
textExtraction: 'complex',
headers: {
10: {sorter: 'text'} // 10 is the column number starting from the sortable columns
}
});
但没有发生变化
如何修复此问题?
控制器/视图模型
public class Row
{
public string Col1 { get; set; }
public string Col2 { get; set; }
public string Col3 { get; set; }
public string Col4 { get; set; }
public string Col5 { get; set; }
public string Col6 { get; set; }
public string Col7 { get; set; }
public string Col8 { get; set; }
public string Col9 { get; set; }
public string Col10 { get; set; }
}
public class Table
{
public IList<Row> Rows { get; set; }
}
public class HomeController : Controller
{
public ActionResult Index20()
{
var viewModel = new Table { Rows = new List<Row>() };
var row1 = new Row
{
Col1 = "Col1",
Col2 = "Col2",
Col3 = "Col1",
Col4 = "Col4",
Col5 = "Col5",
Col6 = "Col6",
Col7 = "Col7",
Col8 = "Col8",
Col9 = "Col9",
Col10 = "Yes"
};
var row2 = new Row
{
Col1 = "Col1",
Col2 = "Col2",
Col3 = "Col1",
Col4 = "Col4",
Col5 = "Col5",
Col6 = "Col6",
Col7 = "Col7",
Col8 = "Col8",
Col9 = "Col9",
Col10 = "No"
};
var row3 = new Row
{
Col1 = "Col1",
Col2 = "Col2",
Col3 = "Col1",
Col4 = "Col4",
Col5 = "Col5",
Col6 = "Col6",
Col7 = "Col7",
Col8 = "Col8",
Col9 = "Col9",
Col10 = "Yes"
};
var row4 = new Row
{
Col1 = "Col1",
Col2 = "Col2",
Col3 = "Col1",
Col4 = "Col4",
Col5 = "Col5",
Col6 = "Col6",
Col7 = "Col7",
Col8 = "Col8",
Col9 = "Col9",
Col10 = "No"
};
var row5 = new Row
{
Col1 = "Col1",
Col2 = "Col2",
Col3 = "Col1",
Col4 = "Col4",
Col5 = "Col5",
Col6 = "Col6",
Col7 = "Col7",
Col8 = "Col8",
Col9 = "Col9",
Col10 = "Yes"
};
viewModel.Rows.Add(row1);
viewModel.Rows.Add(row2);
viewModel.Rows.Add(row3);
viewModel.Rows.Add(row4);
viewModel.Rows.Add(row5);
return View(viewModel);
}
公共类行
{
公共字符串Col1{get;set;}
公共字符串Col2{get;set;}
公共字符串Col3{get;set;}
公共字符串Col4{get;set;}
公共字符串Col5{get;set;}
公共字符串Col6{get;set;}
公共字符串Col7{get;set;}
公共字符串Col8{get;set;}
公共字符串Col9{get;set;}
公共字符串Col10{get;set;}
}
公共类表
{
公共IList行{get;set;}
}
公共类HomeController:控制器
{
公共行动结果索引20()
{
var viewModel=new Table{Rows=new List()};
var row1=新行
{
Col1=“Col1”,
Col2=“Col2”,
Col3=“Col1”,
Col4=“Col4”,
Col5=“Col5”,
Col6=“Col6”,
Col7=“Col7”,
Col8=“Col8”,
Col9=“Col9”,
Col10=“是”
};
var row2=新行
{
Col1=“Col1”,
Col2=“Col2”,
Col3=“Col1”,
Col4=“Col4”,
Col5=“Col5”,
Col6=“Col6”,
Col7=“Col7”,
Col8=“Col8”,
Col9=“Col9”,
Col10=“否”
};
var row3=新行
{
Col1=“Col1”,
Col2=“Col2”,
Col3=“Col1”,
Col4=“Col4”,
Col5=“Col5”,
Col6=“Col6”,
Col7=“Col7”,
Col8=“Col8”,
Col9=“Col9”,
Col10=“是”
};
var row4=新行
{
Col1=“Col1”,
Col2=“Col2”,
Col3=“Col1”,
Col4=“Col4”,
Col5=“Col5”,
Col6=“Col6”,
Col7=“Col7”,
Col8=“Col8”,
Col9=“Col9”,
Col10=“否”
};
var row5=新行
{
Col1=“Col1”,
Col2=“Col2”,
Col3=“Col1”,
Col4=“Col4”,
Col5=“Col5”,
Col6=“Col6”,
Col7=“Col7”,
Col8=“Col8”,
Col9=“Col9”,
Col10=“是”
};
viewModel.Rows.Add(第1行);
viewModel.Rows.Add(第2行);
viewModel.Rows.Add(第3行);
viewModel.Rows.Add(第4行);
viewModel.Rows.Add(第5行);
返回视图(viewModel);
}
看法
@model WebApplication2.Controllers.Table
@使用WebApplication2.Controller
@{
布局=空;
}
Index20
@*https://mottie.github.io/tablesorter/docs/*@
$(函数(){
$(“#myTable”).tablesorter();
});
可乐
可乐
可乐
可乐
可乐
可乐6
可乐
可乐
可乐
可乐
@foreach(Model.Rows中的行)
{
@第1行
@第2行
@第3行
@第4行
@第5行
@第6行
@第7排
@第8排
@第9行
@第10排
}
@model WebApplication2.Controllers.Table
@using WebApplication2.Controllers
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index20</title>
@*https://mottie.github.io/tablesorter/docs/*@
<!-- choose a theme file -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.29.0/css/theme.default.min.css"
integrity="sha256-kZJ4kB78IbXuxMtCpmaXzii8vxEKtu8pjicH62E0/qM=" crossorigin="anonymous" />
<!-- load jQuery and tablesorter scripts -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.min.js"></script>
<!-- tablesorter widgets (optional) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.widgets.min.js"></script>
<script type="text/javascript">
$(function () {
$("#myTable").tablesorter();
});
</script>
</head>
<body>
<div>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
<th>Col5</th>
<th>Col6</th>
<th>Col7</th>
<th>Col8</th>
<th>Col9</th>
<th>Col10</th>
</tr>
</thead>
<tbody>
@foreach (Row row in Model.Rows)
{
<tr>
<td>
@row.Col1
</td>
<td>
@row.Col2
</td>
<td>
@row.Col3
</td>
<td>
@row.Col4
</td>
<td>
@row.Col5
</td>
<td>
@row.Col6
</td>
<td>
@row.Col7
</td>
<td>
@row.Col8
</td>
<td>
@row.Col9
</td>
<td>
@row.Col10
</td>
</tr>
}
</tbody>
</table>
</div>
</body>
</html>