sorting problem while RadGridView have disabled command buttons

3 posts, 1 answers
  1. Omar
    Omar avatar
    2 posts
    Member since:
    Oct 2014

    Posted 02 Dec 2014 Link to this post

    some of buttons disabled and another buttons are enabled depending on condition 
    the problem is , if you sort the radgridview by clicking the header of data column these enabled buttons will be disabled and disabled buttons somtimes will be enabled , i tried ViewCellFormatting event but have the same problem.
    You can see the attached screenshot before and after sorting ..
     private void grvDepartment_CellFormatting(object sender, CellFormattingEventArgs e)
            {            
                if (e.RowIndex > -1) // not header
                {
                    var cellElement = e.CellElement;
                    int departmentId = Convert.ToInt32(e.Row.Cells["DepartmentId"].Value);                
                    ICollection<UserProfile> usersProfiles =
                         (from u in _outEntities.UserProfile.Local where u.DepartmentId == departmentId select u).ToList();

                    if (usersProfiles.Count > 0)
                    {
                        #region MyRegion
                        if (cellElement.ColumnInfo.Name == "DepartmentName")
                            cellElement.Enabled = false;
                        else if (cellElement.ColumnInfo.Name == "DepartmentAcronum")
                            cellElement.Enabled = false;
                        else cellElement.Enabled = true; 
                        #endregion

                        var cell = cellElement as GridCommandCellElement;
                        if (cell != null)
                        {
                            #region MyRegion
                            if (cell.ColumnInfo.Name == "colUpdate")
                                cell.Enabled = false;
                            //cell.Visibility = ElementVisibility.Hidden;
                            else if (cell.ColumnInfo.Name == "colDelete")
                                //cell.Visibility = ElementVisibility.Hidden; 
                                cell.Enabled = false;
                            else cell.Enabled = true;
                            //cell.Visibility = ElementVisibility.Visible;
                            #endregion
                        }
                    }
                }            
            }



  2. Answer
    Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 04 Dec 2014 Link to this post

    Hi Omar,

    Thank you for writing.

    RadGridView uses UI virtualization
     for its cells, which means that there are only certain amount of cells visible at all times and the data in these cells is being changed when scrolling, sorting, fiktering. Hence it is necessary to reset each visual settings you apply. More information and examples you can find here: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Omar
    Omar avatar
    2 posts
    Member since:
    Oct 2014

    Posted 10 Dec 2014 in reply to Stefan Link to this post

    Thanks for this post.
Back to Top