Hi,
I am using Telerik Controls for WPF Q3 2009 (2009.3.1314.35), .NET 3.5 SP1, Windows XP SP2. I have two problems.
(1)
I have a grid bound to a (strongly typed) DataTable which has two dependent columns (in my project they're bound to the same data but display it differently). My goal is to have one column update when another changes, meaning on CellEditEnded (preferably) or RowEditEned.
For example:
<telerik:RadGridView Name="RadGridView" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Product_Name}" Header="Product Name"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Product_Name}" Header="Product Name Again"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
I want "Product Name Again" to refresh after "Product Name" is edited.
Searching through the forums and experimenting, I couldn't find a solution that completely works.
I should note that the same situation, but when binding to an ObservableCollection of CLR objects, works with no problem.
I tried the following:
When binding to DataTable.DefaultView, the dependent column is affected when UPDATING an existing row, but not when INSERTING a new row.
When inserting, the dependent column refreshes only after entering edit mode again and committing.
When binding directly to DataTable, updating works, but when inserting the new row visually disappears when the editing is finished. I implemented AddingNewDataItem and RowEditEnded to enable inserting.
I did something like this (assuming null is valid for all columns of the products table):
private void RadGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
// _productsDataTable is a strongly typed reference to the DataTable
var product = _productsDataTable.NewProductsRow();
e.NewObject = product;
}
private void RadGridView1_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Insert &&
e.EditAction == Telerik.Windows.Controls.GridView.GridViewEditAction.Commit)
{
_productsDataTable.AddProductsRow(e.NewData as ProductsRow);
}
}
(I also tried adding the row to the table in AddingNewDataItem instead of in RowEditEnded, but got the same result)
Do have any suggestions on what might work?
=============
(2)
I have a grid ordered by a non-visible "priority" field, with CanUserReorderColumns=False. I'm unable to make the ordering refresh when the "priority" changes.
The grid has one column that looks something like this:
Change priority
---------------
[+] [-]
[+] [-]
[+] [-]
If for example, the user clicks [+] on the second row, a command is invoked on a ViewModel class which changes the "priority" values of the first and second rows, so that after reordering the rows will swap places.
A requirement is that the user will always be able to click the buttons in one step, without needing to enter edit-mode first with F2/click etc.
To achieve this, I defined the buttons in the column's CellTemplate and prevented it from ever entering edit mode.
The problem is, after clicking the buttons, the underlying data changes but the grid isn't automatically reordered (which I guess is because the grid isn't aware of any edit action). The underlying data implements INotifyPropertyChanged.
I tried triggering reordering manually, but the buttons' OnClick/OnMouseUp events fire before their commands, so it had no effect.
Thanks in advance,
Yuri
I am using Telerik Controls for WPF Q3 2009 (2009.3.1314.35), .NET 3.5 SP1, Windows XP SP2. I have two problems.
(1)
I have a grid bound to a (strongly typed) DataTable which has two dependent columns (in my project they're bound to the same data but display it differently). My goal is to have one column update when another changes, meaning on CellEditEnded (preferably) or RowEditEned.
For example:
<telerik:RadGridView Name="RadGridView" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Product_Name}" Header="Product Name"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Product_Name}" Header="Product Name Again"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
I want "Product Name Again" to refresh after "Product Name" is edited.
Searching through the forums and experimenting, I couldn't find a solution that completely works.
I should note that the same situation, but when binding to an ObservableCollection of CLR objects, works with no problem.
I tried the following:
When binding to DataTable.DefaultView, the dependent column is affected when UPDATING an existing row, but not when INSERTING a new row.
When inserting, the dependent column refreshes only after entering edit mode again and committing.
When binding directly to DataTable, updating works, but when inserting the new row visually disappears when the editing is finished. I implemented AddingNewDataItem and RowEditEnded to enable inserting.
I did something like this (assuming null is valid for all columns of the products table):
private void RadGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
// _productsDataTable is a strongly typed reference to the DataTable
var product = _productsDataTable.NewProductsRow();
e.NewObject = product;
}
private void RadGridView1_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
if (e.EditOperationType == Telerik.Windows.Controls.GridView.GridViewEditOperationType.Insert &&
e.EditAction == Telerik.Windows.Controls.GridView.GridViewEditAction.Commit)
{
_productsDataTable.AddProductsRow(e.NewData as ProductsRow);
}
}
(I also tried adding the row to the table in AddingNewDataItem instead of in RowEditEnded, but got the same result)
Do have any suggestions on what might work?
=============
(2)
I have a grid ordered by a non-visible "priority" field, with CanUserReorderColumns=False. I'm unable to make the ordering refresh when the "priority" changes.
The grid has one column that looks something like this:
Change priority
---------------
[+] [-]
[+] [-]
[+] [-]
If for example, the user clicks [+] on the second row, a command is invoked on a ViewModel class which changes the "priority" values of the first and second rows, so that after reordering the rows will swap places.
A requirement is that the user will always be able to click the buttons in one step, without needing to enter edit-mode first with F2/click etc.
To achieve this, I defined the buttons in the column's CellTemplate and prevented it from ever entering edit mode.
The problem is, after clicking the buttons, the underlying data changes but the grid isn't automatically reordered (which I guess is because the grid isn't aware of any edit action). The underlying data implements INotifyPropertyChanged.
I tried triggering reordering manually, but the buttons' OnClick/OnMouseUp events fire before their commands, so it had no effect.
Thanks in advance,
Yuri