Hi,
I'm very new on working with Telerik products. The past few days i'm working with RadDataFilter and custom editors but I stuck with the following problem.
My custom editor is a usercontrol witch has a dependency property called SelectedDateRange of type DateRange. The DateRange is a class with two properties
Public Class DateRange
Implements System.ComponentModel.INotifyPropertyChanged
#Region "INotifyPropertyChanged Implementation"
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Protected Sub OnPropertyChanged(ByVal propertyname As String)
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyname))
End Sub
#End Region
Private _beginDate As Date?
<DataMember()>
Public Property BeginDate() As Date?
Get
Return _beginDate
End Get
Set(ByVal value As Date?)
_beginDate = value
OnPropertyChanged("BeginDate")
End Set
End Property
Private _endDate As Date?
<DataMember()>
Public Property EndDate() As Date?
Get
Return _endDate
End Get
Set(ByVal value As Date?)
_endDate = value
OnPropertyChanged("EndDate")
End Set
End Property
Public Function HasRange() As Boolean
Return BeginDate.HasValue Or EndDate.HasValue
End Function
End Class
Using your example i'm trying to bind the SelectedDateRange with the Value Property of the FilterDescriptor using the following statement
<DataTemplate x:Key="DateRangeBlockEditor">
<AhsSysUIControls:DateRangeBlock SelectedDateRange="{Binding Value,Mode=TwoWay}" />
</DataTemplate>
It seems that this doesn't work as i get always an unsetValue. The bottom line is that i want the FilterDescriptor to carry the DateRange because later i iterate all the FilterDescriptors to create an SQL where statement. Any ideas?
Thanks Sotiris
I have a RadGridView:
<Telerik:RadGridView Name="recordGrid" ItemsSource="{Binding RecordList,Mode=TwoWay}" SelectedItem="{Binding CurrentRecord,Mode=TwoWay}" ShowGroupPanel="False" AutoGenerateColumns="True" AutoGeneratingColumn="RadGridView_AutoGeneratingColumn"> </Telerik:RadGridView> As you can see, the grid is bound to a DataTable object called RecordList and the SelectedItem is bound to a DataRow object called CurrentRecord. The RecordList DataTable is generated dynamically and can have any combination of user-defined columns and rows. Because I don't know the columns ahead of time, I use AutoGenerateColumns to take care of that.
The first column will always be an ID column that identifies the row and is hidden from the user by canceling the AutoGenerateColumn event whenever the column header is "ID". The rest of the columns are user defined.
Up to there, it all works. The problem comes when I need to create a custom column type to be auto-generated. Some columns, as defined by the user, need to display other UI controls such as buttons in the cell. To do this, I've created a RecordColumn class that extends Telerik.Windows.Controls.GridViewColumn. It is defined as follows:
public class RecordColumn : Telerik.Windows.Controls.GridViewColumn { public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem) { StackPanel cellData = new StackPanel(); return cellData; } }Nothing fancy at the moment. Just trying to get it working so all it does is return an empty StackPanel to go in the cell when it's created.
Now, here's my AutoGeneratingColumns event code, which I use to instantiate the RecordColumn.
private void RadGridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e) { String headerText = e.Column.Header.ToString(); if (headerText == "ID") { e.Cancel = true; } else { if (!(e.Column is RecordColumn)) { RecordColumn rc = new RecordColumn(); rc.Header = headerText; e.Column = rc; } } } The first time the RadGridView is loaded, everything looks fine. The user-defined columns are displayed as expected. If I do anything that causes the RecordList DataTable binding to update (such as adding or deleting a row), the AutoGeneratingColumns event fires again and doubles the columns. I can keep doing this, causing the columns to double every time.
I can trace the AutoGeneratingColumns event being fired each time and it always (except for the "ID" column) goes into the code that creates a new RecordColumn. I'm guessing that's where it's creating the extra columns each time. Looking through the e.Column object though, I don't see anything that tells me I don't need to generate this column again. Each time the column type is RadGridViewColumn even if I've previously changed them all to RecordColumn, so that doesn't work.
I have verified that my DataTable on the back-end only contains one set of the columns. This is purely on the UI side.
If I don't use the custom column, everything works fine and when I update the binding the columns don't duplicate.
