Click here to Skip to main content
15,667,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a webgrid in my view as follows:
C#
      @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")
)

for a certain user i have hidden the 3rd column using javascript like below:
JavaScript
     $(document).ready(function () {
    hideColumnColorRow(3); //hide Contact No. column
});

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

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....
Posted
Updated 7-Apr-13 23:08pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900