GridViewCell improvements

2 posts, 0 answers
  1. Alden
    Alden avatar
    2 posts
    Member since:
    Sep 2012

    Posted 02 Jul 2013 Link to this post

    Generally feel like I am using workarounds instead of the more intentional programming I want to be doing for these basic things that I am used to doing in other grids, it seems like I need a new custom GridViewCell or something there is a growing list of improvements I am making that I wish there were a better way to do. 

    The idea of seeing which cells are edited is cool, but it only seems to work notice the last change that was made for a cell.  Since the edited style doesn't notice when the user undoes their changes to the true Original uncommitted value.  Worse yet when edit events fire that don't actually change the value sometimes the cell is marked as un-edited even though it has changes.  So far, I have been putting them in the tag property:


            private void HandelPasting(object sender, GridViewClipboardEventArgs e)
            {
                foreach (GridViewCell cell in SelectedItems)
                {
                    //store the original value so we can tell if we have just reverted to it.
                    cell.Tag = cell.Tag == null ? cell.Value : cell.Tag;
                }
            }        {
                foreach (GridViewCell cell in SelectedItems)
                {
                    //store the original value so we can tell if we have just reverted to it.
                    cell.Tag = cell.Tag == null ? cell.Value : cell.Tag;
                }
            }

    Then I adjust the background based on whether the value changed:

                    cell.Background = !newData.HasValueChanged(cell.Tag) ? CLEANBRUSH : DIRTYBRUSH;
    //Bug in Telerik grid requires this to get the cell background updated.
                    Grid gridFromVisualTree = (Grid)VisualTreeHelper.GetChild(cell, 0) as Grid;
                    if (gridFromVisualTree != null)
                    {
                        gridFromVisualTree.Background = cell.Background;
                    }

    Next I want to o set the cells(not the row or the header) tool tip with this original value.  I am trying something like this:

    GridViewRow RowFound = gridView.ChildrenOfType<GridViewRow>().Where(w => w.Item == cellInfo.Item).FirstOrDefault();
    GridViewCellBase cellFound = RowFound.Cells.Where(c => c.Column == cellInfo.Column).FirstOrDefault();
    ((GridViewCell)GridViewCell).ToolTipCache =new ToolTip() { Content =  "My hover text"};

    It is weird, if I set the value in the immediate window, locals or a watch while I am debugging the value gets updated but I can't compile the project because:

    Error 1 'Telerik.Windows.Controls.GridView.GridViewCell' does not contain a definition for 'ToolTipCache' and no extension method 'ToolTipCache' accepting a first argument of type 'Telerik.Windows.Controls.GridView.GridViewCell' could be found (are you missing a using directive or an assembly reference?)

    Then I hope to provide a context menu or tool tip when there is an original value that will let the users undo, reverting to this original value,

    It would be sweet to add another undo/redo button set at the grid level too that would let users cycle through their changes chronologically, zooming the grid to them and selecting the cells for them as they go back and forth...kind of like a version control system.  I might even come up with a change report to show before and after values once users commit their saves.

    I'll get this together  and or de-scope where I can, but, I was hopping that by posting this, others might be able to help me a little and/or maybe some future version of the grid could deal with these things a little better.

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Jul 2013 Link to this post

    Hello Alden,

    You can try implementing IEditableObject Interface and keep track of the changes made to a particular property. Generally, my recommendation would be to keep the whole logic for old and new values in the data layer rather than properties of the visual elements like cells since the grid is virtualized and that information will be lost once you start scrolling.

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top