PartialViewsを$( '#container')と組み合わせて使用しますかload()htmlの更新はwebgridsで動作しますか?私はPartialViewsを使って通常のHTMLテーブルを更新しましたが、divにラップされたwebgridを使って次のような作業をすることはできません。PartialViewの内容はjquery load()を使用してwebgridを更新しません
javascript内でload()を呼び出すと、webgridを使用して更新されたビルドの形式でjavascript()関数のPartialViewを返しますが、divはwebgridテーブルの内容を更新しません関数。ここで
は、いくつかのコードスニペットは、次のとおりです。
メインページビュー(これは私のモデル内のすべての行とインデックスのアクションから移入されている): (ページのWebGridとドロップダウンリストが含まれています)
@model IEnumerable<Models.Person>
@Html.ListBox("CStatus", null, new { style = "width:104px;" }) @*Multiselect that invokes the filter*@
<div id="gridview" class="gen">@Html.Partial("_Persons", Model)</div> @*Main Webgrid
<script type="text/javascript">
$("select").multiselect({
click: function (event, ui) {
alert('hello');
$.get('@Url.Action("Filter")', function (data) {
window.alert('New filtered data coming from action!');
window.alert(data); @*This comes back with new <table>... html data*@
$('#gridview').load('@Url.Action("Filter")', data); @*not updating table data*@
});
}
});
</script>
レンダリングのWebGrid:
<div id="gridview">
<table class="webgrid"><thead><tr class="head"><th scope="col"> <MORE COLUMN DEFS...then just basic html tr/td tags....
</table>
</div>
コントローラーアクション:
public ActionResult Filter()
{
IList<Person> cs = cs = db.Persons.OrderByDescending(x => x.Id).ToList();
return PartialView("_Persons", cs);
}
_Persons.cshtml共有/部分テンプレートのWebGrid dispalyします
@model IEnumerable<Models.Person>
@{
var grid = new WebGrid(source: Model,
rowsPerPage: 50);
}
@grid.GetHtml(
tableStyle: "webgrid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns(
grid.Column("PersonId", "Id"),
grid.Column("PersonName", "Name")
)
。 $( '#campaigngridview').html(data);でロードします。正しく働いた! – JaJ