This is a migrated thread and some comments may be shown as answers.
Conditionally hiding columns
0 Answers 74 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sam Stange
Top achievements
Rank 1
Sam Stange asked on 26 Jan 2011, 03:58 PM
I'm trying to hide a column conditionally, but having some trouble. I can get the column to "hide", but the header and footer row still shows up and the data is moved over one column. I've tried it various ways, but that header row/footer still shows up. Is this a bug?

Here's the code I'm using to conditionally hide the delete action.

@(Html.Telerik().Grid(Model)
    .Name("Grid")
     
    .Sortable()
    .Pageable(pager => pager.PageSize(15))
        .Columns(columns =>
        {
            columns.Template(@<text><a href="PreviewEmail/@item.EmailID" class="Preview">View Email</a></text>).Width(50).Title("View Email");
            columns.Template(o => Html.ActionLink("Delete", "DeleteEmail", new { id = o.EmailID })).Width(50).Title("Delete");
            columns.Bound(o => o.ParentOrgName).Width(300).Title("Parent Org");
            columns.Bound(o => o.ToAddress).Width(250).Title("To://");
            columns.Bound(o => o.JobRequestID).Hidden(true);
            columns.Bound(o => o.WorkItemID).Hidden(true);
            columns.Bound(o => o.EmailID).Hidden(true);
            })
        .CellAction(cell =>
        {
            if (cell.Column.Title == "Delete")
            {
                if (cell.DataItem.JobStatus.JobRequestStatusName == "Emails Sent") //check whether to hide the cell
                {
                    cell.Column.Hidden = true;
                    cell.Column.HeaderHtmlAttributes["style"] = "visibility:hidden";
                    cell.HtmlAttributes["style"] = "visibility:hidden";
                    cell.Column.HtmlAttributes["style"] = "visibility:hidden";
               }
            }
        }
        )
    )
Tags
Grid
Asked by
Sam Stange
Top achievements
Rank 1
Share this question
or