Multiple values changing with Multiple Selection

6 posts, 0 answers
  1. Clinton
    Clinton avatar
    22 posts
    Member since:
    May 2011

    Posted 29 Dec 2011 Link to this post

    Hi there,

    I'm attempting to get all the rows that are selected to change to a value that has been changed in one of the selected rows.

    I've written CreateCellEditElement and CreateCellElement which work really well for single selections.

    var selectedRows = cell.ParentRow.GridViewDataControl.SelectedItems;
     
    foreach (DataRow thisRow in selectedRows)
    {
       thisRow[ thisRow.ColumnIndex(m_ColumnDefinition.CaptionField.Identity)] = "New value here";
    }

    This works to find the rows that are SelectedItems based on the column int.  But the new value does not populate.

    I would prefer to get the GridViewCell for that particular Column of the Row then parse the object that way.

    Could you assist?

    Thank you

    Clinton Rocksmith


  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Dec 2011 Link to this post

    Hello,

     Generally it is not a good idea to work with the visual elements (i.e. rows and cells). You would better work with the data elements. 
     
    For example you can cast each SelectedItem to the bound data item. Then set the property in the particular column for every item.

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Clinton
    Clinton avatar
    22 posts
    Member since:
    May 2011

    Posted 02 Jan 2012 Link to this post

    Hi there,

    I'm aware of the "normal" way of doing this.  However we have our own DataBinding implementation that does not derive from INotifyPropertyChanged like Silverlight databinding does.

    What we'd like to happen is for multiple rows to be selected, then the values that are entered into one CELL are duplicated into all the other currently selected Rows in that same Column.

    Do you have any other way this could be done?

    Thank you

    Clinton
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 03 Jan 2012 Link to this post

    Hi Clinton,

     If you are using your own DataBinding implementation, then it would be better if you could send us a small runnable project.

    Otherwise we may not guess what needs to be changed so that the new values to be populated. 

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Tarcisis
    Tarcisis avatar
    29 posts
    Member since:
    Nov 2010

    Posted 11 Jan 2012 Link to this post

    Hi,

    I´m looking a solution for this!!
    It is possible ?

    Thanks
  6. Clinton
    Clinton avatar
    22 posts
    Member since:
    May 2011

    Posted 11 Jan 2012 Link to this post

    Hey Tarcisis,

    It is possible.  However you'll have to override your CreateCellEditElement and CreateCellElement methods in your Column class.

    The way we went around it was to create an object with a reference to each cell, this was done in CreateCellEditElement.
    List<GridViewCellInfo> cellCollectionToBeReturned = new List<GridViewCellInfo>( );
    var selectedCells = cell.ParentRow.GridViewDataControl.SelectedCells;
    foreach ( GridViewCellInfo selectedCell in selectedCells )
    {
    if( selectedCell.Column.Equals( this ) )
    {
    cellCollectionToBeReturned.add( selectedCell);
    }
    }
     
    cell.Tag = cellCollectionToBeReturned;

    After this, you can call.

    base.CreateCellEditElement( cell, dataItem );

    What's really interesting is the cell.Tag stores all the cells that you would like to update with the new value.....

    then in CreateCellElement.....

    if ( cell.Tag != null ) {
    List< GridViewCellInfo > theCollectionOfCells = cell.Tag as List< GridViewCellInfo >;
     
    foreach ( GridViewCellInfo changeableCell in theCollectionOfCells )
    {
    // do something to make sure changeableCell is not equal to the current cell.
     
    // update your dataTable via dataItem and cell reference you now have
     
    }
     
    // Trigger the INotifyChanged Binding to update the RadGridView, which should probably happen in the DataTable.
     
    }

    Of course, you'll need to experiment, ours is completely different Data Structure with Cell Objects and Cell Properties, so our Data Reference is a little more complex.  But I trust this may help you.

    Cheers

    Clinton
Back to Top