Colspan override...

5 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 22 Jul 2009 Link to this post

    Hi,

    I have a master / detail grid and do some customization in PreRender.
    First - hide the expand collapse column on expanded rows.
    Give the TD holding the details table a CssClass
    Suggestion: it would be much easier for customization if you could give this TD a css-class.

    Anyhow - since I hide the first TD (expand collapse) the second TD must span one column more.
    I tried this with increment - and (since it did not work) with a constant value.
    But the setting is ignored - when I look the rendered HTML the colspan is like it was (no matter what I set in code behind).

    Here my code:
    protected void rgJugendliche_PreRender(object sender, EventArgs e) {  
        if (!IsPostBack) {  
            foreach (GridNestedViewItem nVI in rgJugendliche.MasterTableView.GetItems(GridItemType.NestedView)) {  
                if (nVI.NestedTableViews.Length > 0) {  
                    TableCell tC = nVI.Controls[0] as TableCell;  
                    tC.BackColor = Color.FromArgb(1,0xcd,0xff,0xb1);  
                    tC.Visible = false;  
                    tC = nVI.Controls[1] as TableCell;  
                    tC.ColumnSpan = 11;  
                    tC.CssClass += " BorderTopBottom";  
                }  
            }  
        }  
    }  
     
    11 was just a try - the "default" is 9 - 10 should be what I set - but I can do what I want - it stays 9.

    Regards

    Manfred
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 27 Jul 2009 Link to this post

    Hello ManniAT,

    Even though the nested item template cell does not have a CSS class of its own, you can use the .rgDetailTable CSS class to apply styling.

    If you need to hide the expand/collapse column in RadGrid, you do not need to manually hide each cell and then set the colspan of the detail cell. Simply use

    div.RadGrid_[SkinName] table.rgMasterTable td.rgExpandCol
    {
        display:none;
    }


    Where [SkinName] is the name of the skin you are using for RadGrid. This will hide the entire expand/collapse column without the need to increase the column span of the inner detail cell.

    Sincerely yours,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Jul 2009 Link to this post

    Hi,

    this CSS removes all Expand/collapse.
    What I did with my code (therefore the if for nestedviewitem) is to remove the expand/collapse of the detail tables only.
    So the master still shows the Expand/Collapse (I need it to expand) but the "inner part" of the expanded item (the "holder" for the detail tables) is displayed without the useless column.

    And as you said - unfortunately this nested item template cell does not have a CSS class of it's own. Therefore a CSS approach wont work.

    Regards

    Manfred
  5. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 30 Jul 2009 Link to this post

    Hello ManniAT,

    I now better understand your requirements. Take a look at the sample page I am sending you. You can also insert it in a web site to run. The few lines of code that you need to go RadGrid's ItemCreated event:

    void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        if (e.Item is GridNestedViewItem) 
        { 
            GridNestedViewItem item = e.Item as GridNestedViewItem; 
            item.Cells[0].Style["display"] = "none"
            int newColSpanValue = item.NestedViewCell.ColumnSpan + 1; 
            item.NestedViewCell.Attributes["colspan"] = newColSpanValue.ToString(); 
        } 

    You can see that I hide the first cell (as expected), but the I increase the nested view cell's colspan using its Attributes collection, instead of through its ColumnSpan property. Check this out.

    Best wishes,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 31 Jul 2009 Link to this post

    Hi Veli,

    thank you for the tip about attributes.
    I changed my existing code to:
    foreach (GridNestedViewItem nVI in rgJugendliche.MasterTableView.GetItems(GridItemType.NestedView)) {  
        if (nVI.NestedTableViews.Length > 0) {  
            TableCell tC = nVI.Controls[0] as TableCell;  
            //tC.BackColor = Color.FromArgb(1, 0xcd, 0xff, 0xb1);  
            tC.Visible = false;  
            tC = nVI.Controls[1] as TableCell;  
    //tC.ColumnSpan=tC.ColumnSpan+1; //CHANGE  
            int newColSpanValue = tC.ColumnSpan + 1; //CHANGE  
            tC.Attributes["colspan"] = newColSpanValue.ToString(); //CHANGE  
            tC.CssClass += " BorderTopBottom";  
        }  
     
    Now it works as intended.

    And once again (as usual) great support
    Manfred
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017