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

Breaking Changes in the 2008 Q2 GridView Event Model

1 Answer 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 05 Jul 2009, 02:13 PM
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

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 06 Jul 2009, 10:07 AM
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.
Tags
GridView
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Jack
Telerik team
Share this question
or