I have a GridViewDataColumn in which I need the cells to use/display a mask both in view/edit mode. In order to do this I have set the CellTemplate and the CellEditTemplate as you can see below. I cannot use the GridViewMaskedInputColumn because it does not allow me to specify different masks per cell. One mask per column will not work in my scenario (see attached picture).
There is a slight difference between view and edit mode that I would like help with. In edit mode, the RadMaskedTextBox fills the cell, but in view mode, the RadMaskedTextBox does not quite fill the cell. I would like masked textbox to fill the cell regardless of whether it is in edit or view mode.
I have considered putting a Margin="3,0,0,0" on the CellEditTemplate, this means the textbox will not fill the cell in either view/edit mode - not idea....
<
telerik:GridViewDataColumn
Header
=
"Value"
ValidatesOnDataErrors
=
"InEditMode"
DataMemberBinding
=
"{Binding Value}"
Width
=
"*"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:RadMaskedTextInput
Mask
=
"{Binding ValueMask}"
Value
=
"{Binding Value}"
TextMode
=
"MaskedText"
IsEnabled
=
"False"
SelectionOnFocus
=
"CaretToBeginning"
IsLastPositionEditable
=
"False"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
<
telerik:GridViewDataColumn.CellEditTemplate
>
<
DataTemplate
>
<
telerik:RadMaskedTextInput
Mask
=
"{Binding ValueMask}"
Value
=
"{Binding Value}"
TextMode
=
"MaskedText"
SelectionOnFocus
=
"CaretToBeginning"
IsLastPositionEditable
=
"False"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellEditTemplate
>
</
telerik:GridViewDataColumn
>
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