0

Grid.MVC の並べ替えが期待どおりに機能しない。たとえば、数値と日付値を持つ列があります。提供されているスクリーン ショットは、合計保険料の並べ替えが正しく機能していないことのみを示していますが、発効日列でも同じことが起こります。正しくソートされるように、数字または日付を伝えるために何か追加する必要がありますか?

@Html.Grid(Model.SearchResult).Named("searchGrid").Columns(col =>
{
col.Add(c => c.PolicyNumber).Titled("Number").Sortable(true);
col.Add(c => c.FormattedInsuredName).Titled("Insured Name").Sortable(true);
col.Add(c => c.FormattedAddress).RenderValueAs(m => Html.Raw(m.FormattedAddress)).Encoded(false).Sanitized(false).Titled("Property Address").Sortable(true);
col.Add(c => c.Status).Titled("Status").Sortable(true);
col.Add(c => c.FormattedEffectiveDate).Titled("Effective Date").Sortable(true);
col.Add(c => c.FormattedTotalPremium).Titled("Total Premium").Sortable(true);
col.Add().Encoded(false).SetWidth(150).Sanitized(false).Titled("Action").RenderValueAs(dd => Html.DropDownList("ddlAction", dd.DropDownActions, new { @class = "form-control ddlAction", @data_viewquote = dd.QuoteURL }));
}).WithPaging(25).Sortable(true)

以下のスクリーンショットから、Total Premium 列が正しくソートされていないことがわかります。ASC と DESC の両方のスクリーン ショットがあります。

ここに画像の説明を入力

ここに画像の説明を入力

4

1 に答える 1

0

サンティさん、コメントありがとうございます。

モデルのタイプは、グリッドに到達する前に特定の形式を示すために文字列にフォーマットされていました。文字列の書式設定を削除し、書式設定をグリッドに配置して、適切なタイプで並べ替えを行い、書式設定を表示できるようにしました。追加の .Format() ピースを含む下の新しいグリッド。

@Html.Grid(Model.SearchResult).Named("searchGrid").Columns(col =>
{
   col.Add(c => c.PolicyNumber).Titled("Number").Sortable(true);
   col.Add(c => c.FormattedInsuredName).Titled("Insured Name").Sortable(true);
   col.Add(c => c.FormattedAddress).RenderValueAs(m => Html.Raw(m.FormattedAddress)).Encoded(false).Sanitized(false).Titled("Property Address").Sortable(true);
   col.Add(c => c.Status).Titled("Status").Sortable(true);
   col.Add(c => c.FormattedEffectiveDate).Titled("Effective Date").Sortable(true).Format("{0:MM/dd/yyyy}");
   col.Add(c => c.FormattedTotalPremium).Titled("Total Premium").Sortable(true).Format("{0:C2}");
   col.Add().Encoded(false).SetWidth(150).Sanitized(false).Titled("Action").RenderValueAs(dd => Html.DropDownList("ddlAction", dd.DropDownActions, new { @class = "form-control ddlAction", @data_viewquote = dd.QuoteURL }));
}).WithPaging(25).Sortable(true)
于 2016-10-06T17:54:28.620 に答える