0

I have WebGrid id="EmployeeGrid". I want to hide/remove a specific column say column 4 within this grid. I am using below code using jquery but it hide column 4 of all grid in this page. I want to hide a column of a specific grid using jquery.

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


        };
    })(jQuery);
    $(document).ready(function ()
    { hideColumn(4);
    }); 
user3477335
  • 165
  • 1
  • 2
  • 12

1 Answers1

0

This should work:

hideColumn = function(column)
            {
                $('tr').each(function(){
                    $(this).find('td').eq(column).hide();
                    $(this).find('th').eq(column).hide();
                });
            };

or

hideColumn = function(column)
            {
                $('tr').each(function(){
                    $(this).find('td,th').eq(column).hide();
                });
            };

or even

hideColumn = function(column)
            {
                $( "tr td:nth-child(" + column + "), tr th:nth-child(" + column + ")").hide();
            };
KellyCode
  • 728
  • 6
  • 12