Breaking Changes in the 2008 Q2 GridView Event Model

2 posts, 0 answers
  1. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 05 Jul 2009 Link to this post

    After upgrading to 2008 Q2 my application crashes in several grid event handlers.

    For example the CellFormatting event is now also fired for the Filter Row and when the event handler wants to get the data for the cell, it's obviously Null when the grid loads and no filter is set.

    If there are there are other breaking changes to the Grid, please update the documentation.

    Worked Pre Q2:
           void _grid_CellFormatting(object sender, CellFormattingEventArgs e)  
            {  
                if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridTableHeaderRowElement))  
     
                {  
     
                    GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo;  
     
                    if (column.FieldName == "Minutes")  
                    {  
                        int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value;  
                        TimeSpan ts = TimeSpan.FromMinutes(minutes);  
                        e.CellElement.Text = string.Format("{0:00}:{1:00}", ts.Hours, ts.Minutes);  
     
     
     
     

    Now have to add an additional test (plus additional test of NULL returned by the DB which is not currently possible by the Data Definition).

          void _grid_CellFormatting(object sender, CellFormattingEventArgs e)  
            {  
                if (e.CellElement.ColumnInfo is GridViewDataColumn && (!(e.CellElement.RowInfo is GridViewFilteringRowInfo)) &&                                  
                    (!(e.CellElement.RowElement is GridTableHeaderRowElement)))  
                {  
     
                    GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo;  
     
                    if (column.FieldName == "Minutes")  
                    {  
                        if(e.CellElement.RowInfo.Cells["Minutes"].Value!=null)  
                        {  
                            int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value;  
                            TimeSpan ts = TimeSpan.FromMinutes(minutes);  
                 

    regards
    Erwin
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 06 Jul 2009 Link to this post

    Hi erwin,

    Thank you for bringing our attention to this issue. Yes, I confirm that in this latest version CellFormatting event is fired also for filter cells. This is so, because right now the GridFilterCellElement inherits from GridDataCellElement. We will correct this behavior in our upcoming service pack. I have updated your Telerik points. Should you have any questions, don't hesitate to ask.

    Best wishes,
    Jack
    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 WinForms is Visual Studio 2017 Ready
Back to Top