그래서 대부분의 예제가 크게 복잡해졌습니다. 좋은 예 그것은 키가 내 경우에는 grid
는 해당 부동산 ajaxUpdateContainerId
에 밝혀 here
찾을 수 있습니다.
이것은 전체 페이지를 자동으로 새로 고치지 않고도 작동하도록 그리드를 연결합니다.
나는 적절한 구문을 제공하기 위해 노력하고있는 일부 코드를 게시했습니다.
@{
WebGrid webGrid = new WebGrid(canSort: false, canPage: true, rowsPerPage: 5, ajaxUpdateContainerId: "grid");
webGrid.Bind(Model, autoSortAndPage: false, rowCount: Model.TotalItemCount);
}
<div id="grid">
@webGrid.GetHtml(alternatingRowStyle: "altrow",
mode: WebGridPagerModes.All,
firstText: "<< first",
previousText: "< previous",
nextText: "next >",
lastText: "last >>",
columns: webGrid.Columns(
webGrid.Column("Name"),
webGrid.Column("State.Name", "State"),
webGrid.Column(header: "",
style: "action",
format: (item) => new HtmlString(Html.ActionLink("edit", "Edit", new { id = item.CityId }).ToString() + " | " +
Html.ActionLink("delete", "Delete", new { id = item.CityId }).ToString()
))))
</div>