编辑: 似乎当我将html中的@ DateTime.Now设置为“ajaxUpdateContainerId”时,单击网格标题时值会更改。网格失去了悬停的绑定。
我有一个WebGrid对象,使用 WebMatrix Razor C WebPages,当排序时丢失了jquery toggleClass声明。这里有一些示例js代码可以帮助。
function reBindHover(){
$('#result tbody').on("hover","tr", function(){
$(this).toggleClass('clickable');
});
}
$(document).ready(function () {
reBindHover(); }
我的.cshtml页面中的服务器端代码。
var signgrid = new WebGrid(datasignstatus, ajaxUpdateContainerId: "result",
//ajaxUpdateCallback: "addCheck",
ajaxUpdateCallback: "reBindHover",
rowsPerPage: 20);
这是如何工作的,所以我在排序后保持悬停?
答案 0 :(得分:0)
执行排序会导致PostBack,因此您需要在排序后通过调用hover
重新绑定reBindHover
函数。
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
//rest of the code that does the sorting
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "reBindHover", "reBindHover();", true);
}