Lost in translation with Radgrid

3 posts, 0 answers
  1. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 07 Sep 2009 Link to this post


    I need some help to finalize my radgrid implementation, being unable after hours of try to have desired fonctionalities.
    Here are my hyposthesis:
    - the grid is displayed in a pagewiew from a tabstrip/multipage having a 100% width,
    - I have 30 k to 200K rows to display,
    - each row contains a variable number of columns, depending of initial sql request: 3 to 30, each column must have a different display width, some need only 30px but some other 300px,
    - user should be able to adapt column width clientside,
    - Columns are autogenerated from datatable but I use Radgrid_ColumnCreated to fix each initial row display parameter, header width and wrap for header and content, some columns are DateTime some integer, Guid or string,
    - row size should not be extended to more than one line, so for some columns, I use content wrap false,
    - I use paging and need vertical scrolling because using a 200 row page size necessitate scrolling in a 20 row display window
    - I have suppressed MaterTable viewstate to limit page size (displaying a radChart in the other Tab)
    - I use the RadGrid needdatasource handler to generate an adapted table to the requet,

    Here is my grid declaration
        <Telerik:RadPageView ID="PageView2" runat="server">  
            <div id='Zone2' style="float:left; position: relative; min-height:400px; min-width:980px; width:100%;">  
                <div id='ExportDiv' runat="server" style="float:left; width: 100%;" > 
                    <asp:ImageButton ID="BtnExport2Excel" SkinID='Export2Excel' AlternateText="" runat="server" style="float:left;" /> 
                    <asp:ImageButton ID="BtnExport2Word" SkinID='Export2Word' AlternateText="" runat="server" style="float:left;" /> 
                <Telerik:RadGrid ID="RadGrid1" runat="server" PageSize='20' AllowPaging="True"  AllowSorting="True" GridLines="None" ShowStatusBar='true' > 
                    <MasterTableView TableLayout='Fixed' > 
                        <Telerik:GridClientSelectColumn UniqueName='SelectColumn'  HeaderStyle-Width="30px"/>  
                    <ClientSettings > 
                        <Selecting AllowRowSelect="True" /> 
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" /> 
                        <Resizing ResizeGridOnColumnResize="true" AllowColumnResize="True" ClipCellContentOnResize="true" /> 
                    <PagerStyle Mode"NextPrevAndNumeric" /> 
    and in codebehind in Page_Load
                RadGrid1.AllowCustomPaging                                      =   true;  
                    RadGrid1.ShowGroupPanel                                     =   false;  
                    RadGrid1.AllowFilteringByColumn                             =   false;   
                    RadGrid1.ClientSettings.AllowDragToGroup                    =   false;  
                    RadGrid1.ClientSettings.Scrolling.EnableVirtualScrollPaging =   false;  
    + in OnInit RadGrid1.MasterTableView.EnableViewState = false;

    With all this I am unable to reach the desired effect:

    1) The column size I fix in Column_Created are not all respected, for exemple I use this code for a GridDateTime column named stractivitytime

            void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)  
                if ( !(e.Column is GridEditableColumn) )  
                string colName                  =   e.Column.HeaderText; //default  
                if ( e.Column is GridBoundColumn )  
                    colName                     =   ((GridBoundColumn)e.Column).DataField.ToLower();  
                    // clipping on values ??? , avoid typecode because we need to transform it on ItemGridDataBound  
                    //if ( ( colName != MNSTR.strtypecode ) || ( colName != MNSTR.strcrmuserid) ||  ( colName != MNSTR.strcrmitemid) )  
                    //    ((GridBoundColumn)e.Column).DataFormatString = "<nobr>{0}</nobr>";     
                else if (e.Column is GridCheckBoxColumn)  
                    colName = ((GridCheckBoxColumn)e.Column).DataField.ToLower();  
                else if (e.Column is GridTemplateColumn)  
                    colName = ((GridTemplateColumn)e.Column).DataField.ToLower();  
                else if (e.Column is GridDropDownColumn)  
                    colName = ((GridDropDownColumn)e.Column).DataField.ToLower();  
                string newName                      =   string.Empty;  
                bool display                        =   true;  
                switch (colName)  
                    case MNSTR.strid:  
                        newName                     =   LocalizeHelper.Localize(MNSTR.id, "Id");  
                        display                     =   Settings[MNSTR.id].ToBool();  
                        e.Column.HeaderStyle.Width  =   new Unit("50px");  
                    case MNSTR.stractivitytime:  
                        newName                     =   LocalizeHelper.Localize(MNSTR.activitytime, "Activity Time");  
                        e.Column.HeaderStyle.Width  =   new Unit("200px");  
                        e.Column.ItemStyle.Wrap     =   false;  
                        display                     =   true;  
    with this code I get a 30px column size for stractivitytime column for witch I need a 200px size.
    Some text column get their desired width, I found no rules for this size attribution.
    I tested in IE8 and FireFix 3.x

    2) resizing of columns doesn't work: when I move the column header right side I obtain a dimension box giving a size, but when I release it, the column size is quite not changed ( I increase it to 300px and get a 32px result on mouse release ?????)
    I tried to play with parameters in Column.Header.Style or Column.ItemStyle  like wrap and width with no results.

    Is it possible to have the desired effects:
    - paging
    - scrolling vertically and horizontally
    - fixing each start column width/wrapping and allowing users to change width

    Thanks for help.


  2. CSurieux
    CSurieux avatar
    465 posts
    Member since:
    Jan 2007

    Posted 07 Sep 2009 Link to this post

    Seems I get the problem: setting display=false for some columns in ColumnCreated breaks everything ?
    Seems a bug ?

  3. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 08 Sep 2009 Link to this post

    Perhaps you could wait until after the ColumnCreated event before you start setting display = true/false? You could also test if the issue comes from just the display property (and not the timing of setting this property) by creating a button that sets the display of a column to true or false.
Back to Top