我正在使用 WebGrid 来显示我的数据库中的数据表。该表有一列包含数量。我希望有人能告诉我为什么这个网格没有排序?
@{
WebGrid grid = new WebGrid(
source: Model,
rowsPerPage: 10,
canPage: true,
canSort: false,
ajaxUpdateContainerId: "grid",
ajaxUpdateCallback: "initGrid",
sortFieldName: "Qty_containers",
sortDirectionFieldName: "ASC"
);
}
<div id="grid" class="ajax">
@grid.GetHtml(
tableStyle: "border", headerStyle: "red",
columns: grid.Columns(
grid.Column(columnName: "Haulier",
header: ResourceContext.Get("Model.ShortTerm.Haulier")),
grid.Column(columnName: "ETA_vessel",
header: ResourceContext.Get("Model.ShortTerm.ETA_vessel"), format:
@<text>
@item.ETA_vessel.ToShortDateString()
</text>),
grid.Column(columnName: "Container_length", header: ResourceContext.Get("Model.ShortTerm.Container_length"), format:
@<text>
@{string length = item.Container_length.ToString();
if(length.Equals("_blank_")){
length = "";
}
else if(length.Equals("_x0032_0_ft")){
length = "20 ft";
}
else{
length = "30 ft";
}
}
@length
</text>),
grid.Column(columnName: "Qty_containers", header: ResourceContext.Get("Model.ShortTerm.Qty_containers"), canSort: true)
)
)
</div>