【发布时间】:2014-02-11 09:14:44
【问题描述】:
我有一个包含 3 个部分视图的主视图。其中一个部分视图包含一个应该是可排序的剑道网格。
@(Html.Kendo().Grid(Model)
.Name("tasksgrid")
.Sortable()
.Filterable()
.HtmlAttributes(new { style = "height:100%; font-size:14px;" })
.Columns(columns =>
{
columns.Bound(e => e.Url).Title("URL").Hidden();
columns.Bound(e => e.Id).Title("ID").Hidden();
columns.Template(@<img src="@item.OperatorCreated.ImageSource" style="width:80px;height:80px;"/>).ClientTemplate(" ").Width(100).Title("Picture");
columns.Bound(e => e.Subject).Template(@<div>
<div style="font-size: 20px;">@item.OperatorCreated.Name</div>
<div>@item.Subject<br />@item.Message</div>
</div>).Title("Details").HtmlAttributes(new {id = "detailcolumn"});
columns.Bound(e => e.DateTimeCreated).Title("Date").Width(100).HtmlAttributes(new { id = "datecolumn" });
})
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(p => p.Id))
)
.Events(events => events.Change("onChange"))
.Scrollable()
)
此部分视图仅在选择其他视图中的某个操作时呈现。然后检索数据以填充网格。
function RefreshTasks(name) {
var serviceUrl = "/Tasks/PopulateTasks?actionname=" + name;
var request = $.post(serviceUrl);
request.done(
function (data) {
$("#tasks").html(data);
}
);
}
在网格上完成排序后,将创建以下 url "localhost:1772/?tasksgrid-sort=DateTimeCreated-desc&tasksgrid-group=&tasksgrid-filter=" 这刷新了整个页面,这意味着我的网格部分视图不再存在。
有没有办法把这个 url 只扔到部分视图中。
我找到了一种方法,可以完全按照我的需要进行此实施。
$("#tasksgrid .k-link").click(function (e) {//call the function when column header is clicked
var thelink = e.target.href;//get the url that would be navigated to on sort
var serviceUrl = thelink;
var request = $.post(serviceUrl);//post the url
request.done(
function (data) {
$("#tasks").html(data);//update div
}
);
return false;//cancels navigation
})
【问题讨论】:
标签: asp.net-mvc kendo-ui grid asp.net-mvc-partialview