Lib.Web.Mvc.JQuery.JqGrid
追加/編集ボタンを追加する機能を除いて、NuGetの優れたライブラリが機能しています。次のコードを使用してテーブルを初期化しています。
@{
var grid = new JqGridHelper<TVTViewModel>("tuples",
dataType: JqGridDataTypes.Json,
methodType: JqGridMethodTypes.Post,
pager: true,
rowsNumber: 50,
sortingName: "RecordId",
sortingOrder: JqGridSortingOrders.Asc,
url: Url.Action("Details", new { nctId = Model.NctId }),
viewRecords: true,
cellEditingEnabled: true,
cellEditingSubmitMode: JqGridCellEditingSubmitModes.ClientArray
)
.AddActionsColumn("Actions", width: 25,
inlineEditingOptions: new JqGridInlineNavigatorActionOptions { Keys = true },
editButton: false,
deleteOptions: new JqGridNavigatorDeleteActionOptions { Url = Url.Action("Test", "Test") });
}
および次のコントローラー応答コード:
JqGridResponse response = new JqGridResponse()
{
TotalPagesCount = (int)Math.Ceiling((float)totalRecordsCount / (float)request.RecordsCount),
PageIndex = request.PageIndex,
TotalRecordsCount = totalRecordsCount
};
int i = 0;
foreach (TVTViewModel v in viewModels)
{
v.RecordId = i;
response.Records.Add(new JqGridRecord<TVTViewModel>(v.RecordId.ToString(), v));
i++;
}
return new JqGridJsonResult() { Data = response };
ただし、ページがレンダリングされると、追加の列は列のすべての行に対して「未定義」として表示されます。
オンラインでは、いくつかの場所で、私が試しresponse
たresponse.Reader.RepeatItems = false;
ものがあることを確認することが提案されました (そして、機能しませんでした)。他の提案はありますか?