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

Lost in translation with Radgrid

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CSurieux
Top achievements
Rank 2
CSurieux asked on 07 Sep 2009, 07:00 AM
Hello,

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;" /> 
            </div> 
            <Telerik:RadGrid ID="RadGrid1" runat="server" PageSize='20' AllowPaging="True"  AllowSorting="True" GridLines="None" ShowStatusBar='true' > 
                <MasterTableView TableLayout='Fixed' > 
                    <Columns> 
                    <Telerik:GridClientSelectColumn UniqueName='SelectColumn'  HeaderStyle-Width="30px"/>  
                   </Columns> 
                </MasterTableView> 
                <ClientSettings > 
                    <Selecting AllowRowSelect="True" /> 
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" /> 
                    <Resizing ResizeGridOnColumnResize="true" AllowColumnResize="True" ClipCellContentOnResize="true" /> 
                </ClientSettings> 
                <PagerStyle Mode"NextPrevAndNumeric" /> 
            </Telerik:RadGrid> 
        </div> 
    </Telerik:RadPageView> 
 
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) )  
                return;  
            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");  
                    break;  
                case MNSTR.stractivitytime:  
                    newName                     =   LocalizeHelper.Localize(MNSTR.activitytime, "Activity Time");  
                    e.Column.HeaderStyle.Width  =   new Unit("200px");  
                    e.Column.ItemStyle.Wrap     =   false;  
                    display                     =   true;  
                    break;  
etc. 
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.

CS

2 Answers, 1 is accepted

Sort by
0
CSurieux
Top achievements
Rank 2
answered on 07 Sep 2009, 08:31 AM
Seems I get the problem: setting display=false for some columns in ColumnCreated breaks everything ?
Seems a bug ?

CS
0
Schlurk
Top achievements
Rank 2
answered on 08 Sep 2009, 05:20 PM
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.
Tags
Grid
Asked by
CSurieux
Top achievements
Rank 2
Answers by
CSurieux
Top achievements
Rank 2
Schlurk
Top achievements
Rank 2
Share this question
or