This is a migrated thread and some comments may be shown as answers.

Get visible column count to adjust colspan of GridNestedViewItem

2 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 28 Nov 2013, 01:57 PM
Hi Guys,

First time poster and relatively new to Telerik controls, especially the RadGrid! I've been searching for a solution to my problem but as yet have not been able to find one so hopefully someone can help me.

I have a RadGrid which displays form entry submissions and then the data entered for each submission within a detail table. It's all working fine, but being a UI guy I want to alter the Colspan of the table cell in which the detail table sits to one less so there is an equal indentation at either side. I was able to find out how to do this and have used the code below to do so:

protected void gdSubmissions_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridNestedViewItem)
        {
            GridNestedViewItem item = e.Item as GridNestedViewItem;
            int newColSpanValue = item.NestedViewCell.ColumnSpan -1;
            item.NestedViewCell.Attributes["colspan"] = newColSpanValue.ToString();
            item.NestedViewCell.Style.Add("padding", "5px");
            item.NestedViewCell.Style.Add("border-bottom", "1px solid #e8e8e8");
        }
    }

However, now I have a problem where for certain criteria I need to hide certain columns of the grid and when doing so, the colspan is now incorrect and is not taking in to account just the VISIBLE columns. See the attached images to see what I mean.

Here is the code I use to hide the columns:

protected void gdSubmissions_PreRender(object sender, EventArgs e)
    {
        RemoveExpandIconWhenNoRecords(gdSubmissions.MasterTableView);
 
        // Hide Columns
        if (usesApproval)
        {
            gdSubmissions.MasterTableView.GetColumn("Resubmit").Visible = (_submissionStatus == -1);
            gdSubmissions.MasterTableView.GetColumn("Approve").Visible = (_submissionStatus == 0);
            gdSubmissions.MasterTableView.GetColumn("Reject").Visible = (_submissionStatus == 0);
        }
     }

I appreciate that this may or may not be the best way to do this.

Any help is much appreciated.

Rob.

2 Answers, 1 is accepted

Sort by
0
Rob
Top achievements
Rank 1
answered on 28 Nov 2013, 02:00 PM
Also, please ignore the fact that I stated I am a 'UI' guy and I am developing something that looks like Windows XP, unfortunately that is the style I have to work to :P
0
Venelin
Telerik team
answered on 03 Dec 2013, 01:16 PM
Hi Rob,

I am not sure what exactly your scenario is. If you elaborate more and explain your requirements I would be able to propose a suitable to your case solution. Generally, the colspan should adjust automatically when hiding columns.

In the meantime, could you please try to apply the following CSS rule:

.rgMasterTable{
   width: 100% !important;
}

I am looking forward to your reply.

Regards,
Venelin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Rob
Top achievements
Rank 1
Venelin
Telerik team
Share this question
or