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.
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
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
5 Answers, 1 is accepted
0
Hello,
Didie
the Telerik team
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.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Clinton
Top achievements
Rank 1
answered on 03 Jan 2012, 12:43 AM
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
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
0
Hi Clinton,
Didie
the Telerik team
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.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Tarcisis
Top achievements
Rank 1
answered on 11 Jan 2012, 04:48 PM
Hi,
I´m looking a solution for this!!
It is possible ?
Thanks
I´m looking a solution for this!!
It is possible ?
Thanks
0
Clinton
Top achievements
Rank 1
answered on 12 Jan 2012, 02:10 AM
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.
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.....
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
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