Please refer to the attached screen shot, I have a scenario where I would like to update a graph based on the value change in the radSpreadsheet control. I am using MVVM, based on the sample provided by you here http://www.telerik.com/forums/spreadsheet-with-mvvm
Can you please advise how to capture the changed cell value in the viewmodel?
Thanks
Tarun
Can you please advise how to capture the changed cell value in the viewmodel?
Thanks
Tarun
4 Answers, 1 is accepted
0
Hello Tarun,
Thank you for your interest in RadSpreadsheet!
In order to update your graph on cell value changed you may subscribe for the ActiveWorksheet's Cells CellPropertyChanged event. If you are interested only in cell value changes you may additionally use the CellPropertyChangedEventArgs and check whether the changed property name is "CellValue".
Here follows a demo code snippet, showing how exactly you can achieve the described above:
I hope this information is helpful! If you have any other questions or concerns please do not hesitate to contact us again!
Regards,
Deyan
the Telerik team
Thank you for your interest in RadSpreadsheet!
In order to update your graph on cell value changed you may subscribe for the ActiveWorksheet's Cells CellPropertyChanged event. If you are interested only in cell value changes you may additionally use the CellPropertyChangedEventArgs and check whether the changed property name is "CellValue".
Here follows a demo code snippet, showing how exactly you can achieve the described above:
private
const
string
CellValuePropertyName =
"CellValue"
;
private
Cells cells;
public
MainWindow()
{
InitializeComponent();
this
.RadSpreadsheet.ActiveSheetChanged +=
this
.RadSpreadsheet_ActiveSheetChanged;
this
.AttachToCellPropertyChangedEvent();
}
private
void
RadSpreadsheet_ActiveSheetChanged(
object
sender, EventArgs e)
{
this
.DetachFromCellPropertyChangedEvent();
this
.AttachToCellPropertyChangedEvent();
}
private
void
AttachToCellPropertyChangedEvent()
{
this
.cells =
this
.RadSpreadsheet.ActiveWorksheet.Cells;
this
.cells.CellPropertyChanged += Cells_CellPropertyChanged;
}
private
void
DetachFromCellPropertyChangedEvent()
{
if
(
this
.cells !=
null
)
{
this
.cells.CellPropertyChanged -= Cells_CellPropertyChanged;
}
}
private
void
Cells_CellPropertyChanged(
object
sender, CellPropertyChangedEventArgs e)
{
if
(e.Property.Name == CellValuePropertyName)
{
System.Diagnostics.Debug.WriteLine(
"Cell values were changed in range: ({0})"
, e.CellRange);
}
}
I hope this information is helpful! If you have any other questions or concerns please do not hesitate to contact us again!
Regards,
Deyan
the Telerik team
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
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 >>
0

Tarun
Top achievements
Rank 1
answered on 03 Feb 2014, 03:20 PM
Hi Deyan,
Is that how you would do it following MVVM?
Regards,
Tarun
Is that how you would do it following MVVM?
Regards,
Tarun
0

Tarun
Top achievements
Rank 1
answered on 04 Feb 2014, 09:49 AM
Come on, there must be some way to do this using MVVM, attached property may be, can you give me a sample please?
0
Hello Tarun,
Thank you for writing back!
RadSpreadsheet is primary designed for importing, editing and exporting spreadsheet documents. The forum thread you are referring to is MVVM example of binding the whole RadSpreadsheet's Workbook to some ViewModel. However, the control is not designed for supporting cell values binding MVVM scenarios.
In the concrete case you have described you may create your own ViewModel used for the needed bindings and internally this ViewModel should rely on the earlier proposed CellPropertyChanged event.
Let me know if you have further questions!
Regards,
Deyan
the Telerik team
Thank you for writing back!
RadSpreadsheet is primary designed for importing, editing and exporting spreadsheet documents. The forum thread you are referring to is MVVM example of binding the whole RadSpreadsheet's Workbook to some ViewModel. However, the control is not designed for supporting cell values binding MVVM scenarios.
In the concrete case you have described you may create your own ViewModel used for the needed bindings and internally this ViewModel should rely on the earlier proposed CellPropertyChanged event.
Let me know if you have further questions!
Regards,
Deyan
the Telerik team
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
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 >>