在我的部分视图中,我上传了文档和ajax webgrid,它显示了上传的文档。
这是我的部分视图Upload_doc.cshtml
,
@{
WebGrid doc_upload = new WebGrid(null, rowsPerPage: 5, fieldNamePrefix: "g1", pageFieldName: "p1",
ajaxUpdateContainerId: "grid");
doc_upload.Bind(Model.documents, autoSortAndPage: true, rowCount: 5);
}
<div id="ajaxgrid">
<input type="file" id="file" name="file" />
<input type="submit" class="btn btn-warning"/>
<div >
@doc_upload.GetHtml(htmlAttributes: new { id = "grid" }, tableStyle: "table table-bordered", mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>", columns: doc_upload.Columns(
doc_upload.Column("sno", "Serial No.", canSort: true),
doc_upload.Column("docdesc", "Document Title"),
doc_upload.Column("docdt", "Document Date", format: (k) => k.docdt != null ? string.Format("{0:dd-MMM-yyyy}", k.docdt) : ""),
doc_upload.Column(header: "Actions", format: (item) =>
new HtmlString(
Html.ActionLink("View", "ViewDoc", new { sno=item.sno}, new { target = "_blank" }) + " " +
Ajax.ActionLink("Delete", "delete",
new { sno=item.sno }, new AjaxOptions
{
UpdateTargetId = "test",
InsertionMode = InsertionMode.Replace
})
)
)
))
</div>
我的问题是: -
case(i)当我点击标题进行排序时,整个页面都会回复,因为它会占用索引页面,同样会因为分页而失去了ajax的目的。
案例(ii)如果我上传文档然后排序或进行分页,我的webgrid就会消失。
情况(iii)如果我删除文件然后我排序或进行分页,它将再次执行删除功能。
那么,如何更改网格的默认加载页面? 请帮忙!!!谢谢