保留webgrid的当前状态 [英] retain the current state of a webgrid

查看:76
本文介绍了保留webgrid的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视图中有一个webgrid如下:

I have a webgrid in my view as follows:

      @grid.GetHtml(
     tableStyle: "webgrid",
     headerStyle: "head",
     alternatingRowStyle: "alt",
     columns: grid.Columns(
     grid.Column("PersonId", "Id"),
     grid.Column("Name", header: string.Format("Name" + " {0}", grid.SortColumn == "Name" ? grid.SortDirection == SortDirection.Ascending ? "▼" : "▲" : ""), canSort: true, style: "px20"),
     grid.Column("PersonContactNo","Contact No")
)


某个用户的
我使用如下所示的javascript隐藏了第3列:


for a certain user i have hidden the 3rd column using javascript like below:

     $(document).ready(function () {
    hideColumnColorRow(3); //hide Contact No. column
});

(function ($) {
    hideColumnColorRow = function (column) {
        $('td:nth-child(' + column + '),th:nth-child( ' + column + ')').hide();
    };
})(jQuery);



代码在调试时工作正常,但每当我尝试点击名称超链接对列表进行排序时,隐藏列重新出现......如何我是否让webgrid保持其状态???

请求帮助我....


the code works fine while debugging but whenever i try to click on the "Name" hyperlink to sort the list, the hidden column reappears...how do i get the webgrid to retain its state???
pleas help me on this....

推荐答案

document )。ready( function (){
hideColumnColorRow( 3 ); // 隐藏联系号列
});

function
(document).ready(function () { hideColumnColorRow(3); //hide Contact No. column }); (function (


){
hideColumnColorRow = function (column){
) { hideColumnColorRow = function (column) {


' td:nth-​​child(' + column + ' ),th:nth-​​child(' + column + ' )')。hide();
};
})(jQuery);
('td:nth-child(' + column + '),th:nth-child( ' + column + ')').hide(); }; })(jQuery);



代码在调试时工作正常,但每当我尝试点击名称超链接对列表进行排序时,隐藏列重新出现......如何我是否让webgrid保持其状态???

请求帮助我....


the code works fine while debugging but whenever i try to click on the "Name" hyperlink to sort the list, the hidden column reappears...how do i get the webgrid to retain its state???
pleas help me on this....


这篇关于保留webgrid的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆