Hi!
There is any way to create custom aggregate for QueryableDataProvider?
I want to create CustomDistinct aggregate, I did it successfully for LocalDataSourceProvider, and I need it also for QueryableDataProvider.
Here is my code, unfortunately, it is not working at all..
Hi!
There is any way to create custom aggregate for QueryableDataProvider?
I want to create CustomDistinct aggregate, I did it successfully for LocalDataSourceProvider, and I neet also for QueryableDataProvider.
Here is my code, unfurtonately, it is not working at all..
I see "CountDistinct" in "More aggregate options" window, but when i choose it, the pivot got an error.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Linq.Expressions;
using
Telerik.Pivot.Core;
using
Telerik.Pivot.Core.Fields;
using
Telerik.Pivot.Queryable;
namespace
YA.Pivot.Queryable
{
public
class
MyQueryableDataProvider : QueryableDataProvider
{
protected
override
void
OnPrepareDescriptionForField(PrepareDescriptionForFieldEventArgs args)
{
base
.OnPrepareDescriptionForField(args);
if
(args.DescriptionType == DataProviderDescriptionType.Aggregate)
{
var old = args.Description
as
QueryablePropertyAggregateDescriptionBase;
args.Description =
new
CustomPropertyAggregateDescription()
{
PropertyName = old.PropertyName,
FunctionName = old.FunctionName,
AggregateFunction = old.AggregateFunction,
CustomName = old.CustomName,
StringFormat = old.StringFormat
};
}
}
}
internal
class
CustomPropertyAggregateDescription : QueryablePropertyAggregateDescriptionBase
{
private
enum
MyAggregateFunctions
{
CountDistinct = -100
}
protected
override
Cloneable CreateInstanceCore()
{
return
new
CustomPropertyAggregateDescription()
{
AggregateFunction =
this
.AggregateFunction,
CustomName =
this
.CustomName,
FunctionName =
this
.FunctionName,
PropertyName =
this
.PropertyName,
StringFormat =
this
.StringFormat,
StringFormatSelector =
this
.StringFormatSelector,
TotalFormat =
this
.TotalFormat
};
}
private
bool
IsCountDistinct => (
int
)
base
.AggregateFunction == (
int
)MyAggregateFunctions.CountDistinct;
protected
override
Expression CreateAggregateExpression(Expression enumerableExpression,
string
aggregatedValueName)
{
if
(enumerableExpression ==
null
)
{
throw
new
ArgumentNullException(nameof(enumerableExpression));
}
if
(IsCountDistinct)
{
return
CreateCountDistinctExpression(enumerableExpression, aggregatedValueName);
}
return
base
.CreateAggregateExpression(enumerableExpression, aggregatedValueName);
}
private
Expression CreateCountDistinctExpression(Expression enumerableExpression,
string
aggregatedValueName)
{
Type itemType = TypeExtensions.ExtractItemTypeFromEnumerableType(enumerableExpression.Type);
var selectParamExp = Expression.Parameter(itemType,
"e"
);
var selectPropAccessExp = Expression.Property(selectParamExp, aggregatedValueName);
LambdaExpression selectLambdaExpression = Expression.Lambda(selectPropAccessExp, selectParamExp);
var select = Expression.Call(
typeof
(Enumerable),
"Select"
,
new
[] { itemType, selectLambdaExpression.Body.Type },
enumerableExpression,
selectLambdaExpression);
var distinct = Expression.Call(
typeof
(Enumerable),
"Distinct"
,
new
[] { selectLambdaExpression.Body.Type },
select);
var count = Expression.Call(
typeof
(Enumerable),
"Count"
,
new
[] { selectLambdaExpression.Body.Type },
distinct);
return
count;
}
protected
override
IEnumerable<
object
> SupportedAggregateFunctions =>
base
.SupportedAggregateFunctions.Concat(
new
object
[] { MyAggregateFunctions.CountDistinct });
}
internal
static
class
TypeExtensions
{
public
static
Type ExtractItemTypeFromEnumerableType(Type type)
{
var enumerableType = type.FindGenericType(
typeof
(IEnumerable<>));
if
(enumerableType ==
null
)
{
throw
new
ArgumentException(
"Provided type is not IEnumerable<>"
, nameof(type));
}
return
enumerableType.GetGenericArguments().First();
}
private
static
Type FindGenericType(
this
Type type, Type genericType)
{
while
(type !=
null
&& type !=
typeof
(
object
))
{
if
(type.IsGenericType && type.GetGenericTypeDefinition() == genericType)
{
return
type;
}
if
(genericType.IsInterface)
{
foreach
(Type intfType
in
type.GetInterfaces())
{
Type found = intfType.FindGenericType(genericType);
if
(found !=
null
)
{
return
found;
}
}
}
type = type.BaseType;
}
return
null
;
}
}
}
I have used RadGridView with data collection binded to it.
When I try to search for value in selected column with Filter pop up, on selected column,
I am able to filter collection with checkbox selection.
But when I enter value in the pop textbox and press filter button.
It is not filtering the collection.
I have checked both Distinct and filed filter properties of ColumnFilterDescriptor .It seems to look correct .
Can anybody please help me out to solve the problem?
Hello Telerik,
I wanted to do something similar as this:
<
telerik:RadWatermarkTextBox
WatermarkContent
=
"{Resx WatermarkTextBox_AddNew }"
Visibility
=
"{Binding IsNew, Converter={StaticResource VisibilityConverter}}"
>
<
telerik:RadWatermarkTextBox.WatermarkTemplate
>
<
DataTemplate
>
<!--TODO: Do your custom styling here. -->
<
TextBlock
Style
=
"{StaticResource TextBlockValueDefaultStyle}"
Text
=
"{Binding}"
/>
</
DataTemplate
>
</
telerik:RadWatermarkTextBox.WatermarkTemplate
>
</
telerik:RadWatermarkTextBox
>
but for the TextBox part of the control
is there an easy way to do so?
Thank you
when using radwindow.alert, there is a small probability case to throw an System.ArgumentOutOfRangeException,
is any solution to avoid this ?
Hi,
I'm working with RadDocking on a multiple monitor set-up. Let's consider the following scenario:
1. I open my application.
2. I have my View containing RadDocking on a monitor.
3. I drag a RadPane to another monitor.
4. I save the layout using a XML file.
5. I close my application.
6. I disable/unplug the monitor on which I've dragged the RadPane.
7. I open my application, load the layout from that XML and the dragged RadPane doesn't show.
Code-wise at this point, even though that RadPane isn't showing, it still exists and has content.
I'm using RadDocking_PaneStateChange() to get that RadPane and I'm using this to determine if it was saved on that disabled monitor:
bool outOfBounds = (location.X <= SystemParameters.VirtualScreenLeft - screen.Bounds.Width) || (location.Y <= SystemParameters.VirtualScreenTop - screen.Bounds.Height) || (SystemParameters.VirtualScreenLeft + SystemParameters.VirtualScreenWidth <= location.X) || (SystemParameters.VirtualScreenTop + SystemParameters.VirtualScreenHeight <= location.Y);
Is there an inbuilt method that does this for me? If not, could you suggest a better approach, please? :)
Best regards,
Marius
Hello Telerik,
I am having an issue trying to find a way to add a tooltip to each bar in a barseries control.
I have browsed different solutions for it, but none seem to work.
long story short, here is my code
<
telerik:RadCartesianChart
Loaded
=
"chart_Loaded"
x:Name
=
"chart"
Palette
=
"{StaticResource ActualTargetChartPalette}"
ClipToBounds
=
"False"
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:CategoricalAxis
IsInverse
=
"True"
MajorTickStyle
=
"{StaticResource TransparentTickStyle}"
LineStroke
=
"Transparent"
LabelStyle
=
"{StaticResource TextBlockTrendStyle}"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:LinearAxis
ShowLabels
=
"False"
ElementBrush
=
"Transparent"
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:RadCartesianChart.Behaviors
>
My attempt --->
<
telerik:ChartTooltipBehavior
/>
</
telerik:RadCartesianChart.Behaviors
>
<
telerik:RadCartesianChart.Series
>
<
telerik:BarSeries
CategoryBinding
=
"ItemTypeTranslated"
ValueBinding
=
"Actual"
ItemsSource
=
"{Binding ReportingSummaryOrderingTrendDTO.TrendItems}"
CombineMode
=
"None"
ShowLabels
=
"False"
ClipToPlotArea
=
"False"
ToolTipOpening
=
"BarSeries_ToolTipOpening"
sdk:ChartAnimationUtilities.CartesianAnimation
=
"Rise"
>
<
telerik:BarSeries.TooltipTemplate
>
<
ItemContainerTemplate
>
My attempt ----->
<
TextBlock
Text
=
"{Binding ItemToolTip}"
></
TextBlock
>
</
ItemContainerTemplate
>
</
telerik:BarSeries.TooltipTemplate
>
<
telerik:BarSeries.PointTemplate
>
<
DataTemplate
>
<
Rectangle
Fill
=
"{StaticResource ActualBrush}"
Margin
=
"0 0 0 3"
/>
</
DataTemplate
>
</
telerik:BarSeries.PointTemplate
>
<
telerik:BarSeries.LegendSettings
>
<
telerik:SeriesLegendSettings
Title
=
"{Resx ChartLegend_Actual}"
MarkerGeometry
=
"{StaticResource SolidRectLegendGeometry}"
/>
</
telerik:BarSeries.LegendSettings
>
<
telerik:BarSeries.LabelDefinitions
>
<
telerik:ChartSeriesLabelDefinition
Binding
=
"Actual"
Format
=
"{}{0:F1}"
DefaultVisualStyle
=
"{StaticResource TextBlockTrendStyle}"
Strategy
=
"{StaticResource RightAlignedLabelStrategy}"
/>
</
telerik:BarSeries.LabelDefinitions
>
</
telerik:BarSeries
>
<
telerik:BarSeries
CategoryBinding
=
"ItemTypeTranslated"
ValueBinding
=
"Target"
ItemsSource
=
"{Binding ReportingSummaryOrderingTrendDTO.TrendItems}"
CombineMode
=
"None"
sdk:ChartAnimationUtilities.CartesianAnimation
=
"Rise"
>
<
telerik:BarSeries.PointTemplate
>
<
DataTemplate
>
<
Rectangle
Fill
=
"{StaticResource TargetBrush}"
Height
=
"2"
VerticalAlignment
=
"Bottom"
/>
</
DataTemplate
>
</
telerik:BarSeries.PointTemplate
>
<
telerik:BarSeries.LegendSettings
>
<
telerik:SeriesLegendSettings
Title
=
"{Resx ChartLegend_Target}"
MarkerGeometry
=
"{StaticResource LineSeriesLegendGeometry}"
/>
</
telerik:BarSeries.LegendSettings
>
</
telerik:BarSeries
>
</
telerik:RadCartesianChart.Series
>
</
telerik:RadCartesianChart
>
<
telerik:RadLegend
Grid.Column
=
"1"
Grid.Row
=
"1"
Margin
=
"24,4,0,0"
MinWidth
=
"76"
Items
=
"{Binding LegendItems, ElementName=chart}"
/>
I have attached a picture showing where the tooltip should show
thank you for your time
I've had a standard ComboBox working with this code:
<
ComboBox
x:Name
=
"comboWindow1"
SelectedValue
=
"{Binding Window1Page}"
ItemsSource
=
"{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath
=
"ddDashDescription"
SelectedValuePath
=
"ddDashName"
SelectionChanged
=
"comboWindow1_SelectionChanged"
>
<
ComboBox.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type ComboBoxItem}"
>
<
Setter
Property
=
"IsEnabled"
Value
=
"{Binding ddDashEnabled}"
/>
</
Style
>
</
ComboBox.ItemContainerStyle
>
</
ComboBox
>
I switched over to the RadComboBox, thinking I could do almost exactly the same thing. However when I select the drop down, I get no items. If I remove the ContainerStyle then that works a treat.
I've looked at the various examples in the help, but nothing seems to work.
Both these code examples fail:
<
UserControl.Resources
>
<
Style
x:Key
=
"ComboIsEnabledStyle"
TargetType
=
"{x:Type tel:RadComboBoxItem}"
>
<
Setter
Property
=
"IsEnabled"
Value
=
"{Binding ddDashEnabled}"
/>
</
Style
>
</
UserControl.Resources
>
<
tel:RadComboBox
x:Name
=
"comboWindow2"
SelectedValue
=
"{Binding Window2Page}"
ItemsSource
=
"{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath
=
"ddDashDescription"
SelectedValuePath
=
"ddDashName"
ItemContainerStyle
=
"{StaticResource ComboIsEnabledStyle}"
SelectionChanged
=
"comboWindow2_SelectionChanged"
>
</
tel:RadComboBox
>
<
tel:RadComboBox
x:Name
=
"comboWindow1"
SelectedValue
=
"{Binding Window1Page}"
ItemsSource
=
"{Binding listDashData, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath
=
"ddDashDescription"
SelectedValuePath
=
"ddDashName"
SelectionChanged
=
"comboWindow1_SelectionChanged"
>
<
tel:RadComboBox.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type tel:RadComboBoxItem}"
>
<
Setter
Property
=
"IsEnabled"
Value
=
"{Binding ddDashEnabled}"
/>
</
Style
>
</
tel:RadComboBox.ItemContainerStyle
>
</
tel:RadComboBox
>
I amended one of the Telerik ComboBox examples to demonstrate as that does exactly the same thing. Can't attach, so it's available here: ComboBoxCustomFilteringDemo.zip
I'm really stumped as to what I've missed, as this should really be such a simple thing to do.
BTW I'm running the latest 2015.1.225 WPF version
We have an application in which we would like to support a custom clipboard format for copying\pasting in a RadRichTextBox. I have read your article on clipboard support (http://docs.telerik.com/devtools/wpf/controls/radrichtextbox/features/clipboard-support), but that seems to mainly deal with changing which provided clipboard formats are used.
It appears that if I register a custom format provider with ClipboardEx, that would be able to handle pasting the custom format. For example:
ClipboardEx.ClipboardHandlers.Insert(0,
new
ClipboardHandler()
{
ClipboardDataFormat =
"MyCustomDataFormat"
,
DocumentFormatProvider =
new
MyCustomFormatProvider()
});
However, I don't see a way to handle copying a custom format without intercepting the CopyExecutingCommand and adding the custom format the the clipboard. For example:
void
RadRichTextBox_CommandExecuting(
object
sender, CommandExecutingEventArgs e)
{
if
(e.Command
is
CopyCommand)
{
Clipboard.SetData(
"MyCustomDataFormat"
, GetSelectionAsCustomDataFormatString());
}
}
However, I would want to make sure that the default clipboard formats are still added to the clipboard in addition to our custom format.
Can you provide any guidance on the best way to handle copying and pasting a custom clipboard format?
Thank you.