0
コンテキスト:MVC3、JQuery
こんにちは!
テキストボックスに入力することでwebgridをフィルタリングしようとしています。問題は、Ajax.BeginFormを使用すると、webgridを配置する場所全体が複製されます。
本明細書で同じ問題であるjquery.unobtrusive-ajax.min causing strange behavior on the view
コントローラ
Ajax.BeginForm重複表示
[HttpPost] [ChildActionOnly] public ViewResult Files(string filePath) { IEnumerable<File> results = repository.FindBy(f => f.Path.StartsWith(filePath)).Take(5); return View("_grid", results); }
部分図
@model IEnumerable<DAL.File> @{ Layout = null; } @{var grid = new WebGrid(Model, canPage: true, rowsPerPage: 10, ajaxUpdateContainerId: "myGrid"); grid.Pager(WebGridPagerModes.NextPrevious); @grid.GetHtml(tableStyle: "webGrid", headerStyle: "header", alternatingRowStyle: "alt", columns: grid.Columns( grid.Column("Path", "File"), grid.Column("Size", "Size (bytes)", canSort: true), grid.Column("User", "Owner") ))}
メインビュー
@model IEnumerable<DAL.File> @{ Layout = null; } @using (Ajax.BeginForm(new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "myGrid" })) { @Html.TextBox("filePath", null, new { onKeyUp = "$('form').submit()" }) } div id="myGrid"> @Html.Partial("_grid", Model) /div
は、私は本当にそれを必要とする、ヘルプみんなありがとう:)