gpt4 book ai didi

c# - WebGrid 排序不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 16:25:44 24 4
gpt4 key购买 nike

我正在使用 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>

My grid

最佳答案

我也遇到了“WebGrid”的问题。在您的收藏中试试这个:

objectModel.OrderByDescending(d => d.Qty_containers);

关于c# - WebGrid 排序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12636546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com