void customerAttributesGrid_AddingNewDataItem(object sender, telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e){ var grid = e.OwnerGridViewItemsControl; grid.CurrentColumn = grid.Columns[0];}
I have a Radgrid and Datapager which is bound as the code below, the item source is a linq to sql class, the class is queried and the results are converted into a pivot table and both the pager and grid’s source properties are set and the grid has Aggregate Results and sort descriptors added this works well. I have a refresh button on the page but I can’t work out how to clear the pager and grid when the user clicks the button. I have tried your sample code but get errors. Could you please advise on the correct method.
<telerik:RadGridView x:Name="AgedJobsListgrid" ShowGroupPanel="False" telerik:StyleManager.Theme="Office_Black" ShowColumnFooters="True" IsScrolling="False" IsTabStop="False" RowIndicatorVisibility="Collapsed" VerticalAlignment="Stretch" DataContext="{Binding ElementName=radDataPager}" RowHeight="35" FontSize="14"></telerik:RadGridView>
<telerik:RadDataPager x:Name="radDataPager" telerik:StyleManager.Theme="Office_Black"
PageSize="10"
DisplayMode="All"
IsTotalItemCountFixed="True" Source="{Binding AgedListClass}" DataContext="{Binding ElementName=AgedJobsListgrid}" />
‘code used to clear the pager and grid which fails when setting the itemsource to nothing.
radDataPager.Source = Nothing
AgedJobsListgrid.GroupDescriptors.Clear()
AgedJobsListgrid.ItemsSource = Nothing
AgedJobsListgrid.Columns.Clear()
AgedJobsListgrid.AutoGenerateColumns = True
<telerik:RadGridView ItemsSource="{Binding PagedSource, ElementName=radDataPager}" SelectedItem="{Binding Path=SelectedAccount, Mode=TwoWay}" IsBusy="{Binding IsSearchActive}" IsReadOnly="True" CanUserDeleteRows="False" CanUserInsertRows="False" ShowGroupPanel="False" AutoGenerateColumns="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountNumber}" Header="Account #" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FullName}" Header="Name" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Email}" Header="Email" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding OrganizationName}" Header="Organization" /> </telerik:RadGridView.Columns> <telerik:RadGridView.InputBindings> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding DisplayViewCommand}" /> <KeyBinding Key="Enter" Command="{Binding DisplayViewCommand}" /> </telerik:RadGridView.InputBindings> <telerik:RadGridView.RowStyle> <Style> </Style> </telerik:RadGridView.RowStyle></telerik:RadGridView>
<telerik:RadChart ItemsSource="{Binding Chart2Data}" x:Name="chart2" > <telerik:RadChart.SamplingSettings> <telerik:SamplingSettings SamplingThreshold="240" /> </telerik:RadChart.SamplingSettings> <telerik:RadChart.SeriesMappings> <telerik:SeriesMapping LegendLabel="{x:Static p:Resources.Report_MaskingTrail}" > <telerik:SeriesMapping.SeriesDefinition> <telerik:LineSeriesDefinition ShowItemLabels="False" ShowPointMarks="False" ShowItemToolTips="False" /> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping DataPointMember="YValue" FieldName="Y2" /> <telerik:ItemMapping FieldName="XLabel" DataPointMember="XCategory" /> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> <telerik:SeriesMapping LegendLabel="{x:Static p:Resources.Report_CoreLoudness}" > <telerik:SeriesMapping.SeriesDefinition> <telerik:LineSeriesDefinition ShowItemLabels="False" ShowPointMarks="False" ShowItemToolTips="False" /> </telerik:SeriesMapping.SeriesDefinition> <telerik:SeriesMapping.ItemMappings> <telerik:ItemMapping DataPointMember="YValue" FieldName="Y1" /> <telerik:ItemMapping FieldName="XLabel" DataPointMember="XCategory" /> </telerik:SeriesMapping.ItemMappings> </telerik:SeriesMapping> </telerik:RadChart.SeriesMappings> <telerik:RadChart.DefaultView> <telerik:ChartDefaultView > <telerik:ChartDefaultView.ChartArea> <telerik:ChartArea LegendName="legendLive" NoDataString="{x:Static p:Resources.NoMeasurementData}" EnableAnimations="False"> <telerik:ChartArea.AxisX> <telerik:AxisX AutoRange="true" LabelRotationAngle="270" /> </telerik:ChartArea.AxisX> <telerik:ChartArea.AxisY> <telerik:AxisY AutoRange="{Binding Path=Configuration.Chart2ManualConfiguration1, Converter={StaticResource inverseBooleanConverter}}" MinValue="{Binding Path=Configuration.Chart2Minimum1}" MaxValue="{Binding Path=Configuration.Chart2Maximum1}" Step="{Binding Path=Configuration.Chart2YStep1}" Title="{x:Static p:Resources.Chart2_Series_Title}"> <telerik:AxisY.AxisStyles> <telerik:AxisStyles AxisLineStyle="{StaticResource AxisLineStyle}" TickLineStyle="{StaticResource MajorTickLineStyle}" MinorTickLineStyle="{StaticResource MinorTickLineStyle}" ItemLabelStyle="{StaticResource CustomLabel}" /> </telerik:AxisY.AxisStyles> </telerik:AxisY> </telerik:ChartArea.AxisY> </telerik:ChartArea> </telerik:ChartDefaultView.ChartArea> <telerik:ChartDefaultView.ChartLegend> <telerik:ChartLegend x:Name="legendLive" Header="{x:Static p:Resources.ChartLegend}" LegendItemStyle="{StaticResource CustomLegendItem}" Visibility="Collapsed" /> </telerik:ChartDefaultView.ChartLegend> </telerik:ChartDefaultView> </telerik:RadChart.DefaultView> </telerik:RadChart> DispatcherTimer which asks for a new portion of data every second. RadGridView ItemsSource change, with a best performance?