Good day,
I have a radpivotgridview with a custom calculated field, 2 questions:
First one I see in https://docs.telerik.com/devtools/winforms/controls/pivotgrid/calculated-fields to make the custom calculated field from just a value column named ExtendedPrice if I want column a from database div column b from database how could I implement that.
Second I have a calculated field like this:
Public Class TelerikPivotCalculatedFieldDirua
Inherits CalculatedField
Private denboraEuroakField As RequiredField
Public Sub New()
Me.Name = "TotalEuro"
Me.denboraEuroakField = RequiredField.ForProperty("zenbatSeg")
End Sub
Protected Overrides Function RequiredFields() As IEnumerable(Of RequiredField)
Return New List(Of RequiredField) From {denboraEuroakField}
End Function
Protected Overrides Function CalculateValue(aggregateValues As IAggregateValues) As AggregateValue
Dim aggregateValue = aggregateValues.GetAggregateValue(Me.denboraEuroakField)
If aggregateValue.IsError() Then
Return aggregateValue
End If
Dim denboraEuroak As Integer = 0 '= aggregateValue.ConvertOrDefault(Of Integer)()
denboraEuroak = CInt(aggregateValue.GetValue)
If denboraEuroak >= 0 Then
Dim gEurosSeg As Decimal = 0
gEurosSeg = CDec(gEurosHora) / CDec(3600)
Dim gGuztira As Decimal = 0
gGuztira = CDec(denboraEuroak) * CDec(gEurosSeg)
gGuztira = Math.Round(gGuztira, 2, MidpointRounding.AwayFromZero)
Return New DoubleAggregateValue(gGuztira)
End If
Return Nothing
End Function
End Class
In the vb file:
Me.provider = New LocalDataSourceProvider()
'Using rpgestadistica.PivotGridElement.DeferRefresh()
Using provider.DeferRefresh()
Dim calculatedField As New TelerikPivotCalculatedFieldDirua()
calculatedField.Name = "TotalEuro"
calculatedField.DisplayName = Func_nombre(3372)
provider.CalculatedFields.Add(calculatedField)
End Using
'DirectCast(Me.rpgestadistica.DataProvider, LocalDataSourceProvider).CalculatedFields.Add(calculatedField)
'rpgestadistica.DataProvider = provider
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "globalNombre", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(3370)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "tipogasin", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(160)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "suscripcion", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(250)})
Me.provider.RowGroupDescriptions.Add(New PropertyGroupDescription() With {.PropertyName = "razon", _
.GroupComparer = New GroupNameComparer(), _
.CustomName = Func_nombre(174)})
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "total", _
.AggregateFunction = AggregateFunctions.Sum})
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "denbora", _
.AggregateFunction = New TelerikPivotAggregateFunctionEstTiempo()})
'Me.provider.AggregateDescriptions.Add(provider.CalculatedFields.Item(11))
Me.provider.AggregateDescriptions.Add(New PropertyAggregateDescription() With {.PropertyName = "TotalEuro", _
.AggregateFunction = AggregateFunctions.Sum})
'This last line appears like "error".
Me.cargaridiomarpg()
provider.AggregatesPosition = PivotAxis.Columns
provider.AggregatesLevel = 2
Me.provider.ItemsSource = ldt
rpgestadistica.DataProvider = provider
cargaridiomarpg()
For Each rd As RadElement In Me.rpgestadistica.PivotGridElement.ColumnDescriptorsArea.Children
Dim pgde As PivotGroupDescriptorElement = TryCast(rd, PivotGroupDescriptorElement)
If Not IsNothing(pgde) Then
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitRowHeaders(pgde.Level)
End If
Next
For Each element As RadElement In Me.rpgestadistica.PivotGridElement.RowDescriptorsArea.Children
Dim pgde As PivotGroupDescriptorElement = TryCast(element, PivotGroupDescriptorElement)
If Not IsNothing(pgde) Then
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitRowHeaders(pgde.Level)
End If
Next
Me.rpgestadistica.PivotGridElement.BestFitHelper.BestFitColumns()
See Attach file 1, CustomAggregatev1:
If I rightClick and deattach TiempoEuro column and reattach it. I see it ok:
See Attach file 2 and Attach file 3.
How can I achive it like in attach file 3 from the beginning instead of having errors.
Thanks in advance,
Xabi
I want to temporarily disable the arrow keys in the grid. When a row is selected, I do some image processing for that row, which typically takes .25 to 2 seconds. During that processing time, I want to disable the arrow keys during processing and then enable them when done. I created a bool isBusy Flag for the processing, but I cannot add that to the below custom behavior. Any suggestions? Is there a way to toggle the Custom behavior?
public class CustomGridBehavior : BaseGridBehavior
{
public override bool ProcessKey(KeyEventArgs keys__1)
{
switch (keys__1.KeyCode)
{
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
{
return false;
}
default:
{
return base.ProcessKey(keys__1);
}
}
}
}
I have a win form on which I have a radribbon component which was working fine.
After I processed an update to Telerik UI components, the form could no longer open in design mode and attached are the error messages.
It looks like a bug, maybe not.
Could anyone assist?
Ekoue
001.
internal
class
NotificationA : INotification {
002.
public
string
Name {
get
;
set
; }
003.
public
string
Type => nameof(NotificationA);
004.
}
005.
006.
internal
class
NotificationB : INotification {
007.
public
int
Degree {
get
;
set
; }
008.
public
string
Type => nameof(NotificationB);
009.
}
010.
011.
internal
class
NotificationAListItem : RadListVisualItem {
012.
private
LightVisualElement notificationTitleElement;
013.
private
StackLayoutPanel stackLayout;
014.
015.
protected
override
void
CreateChildElements()
016.
{
017.
base
.CreateChildElements();
018.
019.
stackLayout =
new
StackLayoutPanel();
020.
stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical;
021.
022.
notificationTitleElement =
new
LightVisualElement();
023.
notificationTitleElement.TextAlignment = ContentAlignment.MiddleLeft;
024.
notificationTitleElement.Margin =
new
Padding(10);
025.
notificationTitleElement.ForeColor = Color.Black;
026.
stackLayout.Children.Add(notificationTitleElement);
027.
028.
this
.Children.Add(stackLayout);
029.
}
030.
031.
public
override
void
Synchronize()
032.
{
033.
base
.Synchronize();
034.
Text =
string
.Empty;
035.
if
(Data.DataBoundItem
is
not NotificationA n)
return
;
036.
notificationTitleElement.Text = Convert.ToString(n.Name);
037.
}
038.
}
039.
040.
internal
class
NotificationBListItem : RadListVisualItem
041.
{
042.
private
LightVisualElement notificationTitleElement;
043.
private
StackLayoutPanel stackLayout;
044.
045.
protected
override
void
CreateChildElements()
046.
{
047.
base
.CreateChildElements();
048.
049.
stackLayout =
new
StackLayoutPanel();
050.
stackLayout.Orientation = Orientation.Vertical;
051.
052.
053.
notificationTitleElement =
new
LightVisualElement();
054.
notificationTitleElement.TextAlignment = ContentAlignment.MiddleLeft;
055.
notificationTitleElement.Margin =
new
Padding(10);
056.
notificationTitleElement.ForeColor = Color.Black;
057.
stackLayout.Children.Add(notificationTitleElement);
058.
059.
Children.Add(stackLayout);
060.
061.
Padding =
new
Padding(5);
062.
Shape =
new
RoundRectShape(3);
063.
BorderColor = Color.FromArgb(255, 110, 153, 210);
064.
BorderGradientStyle = GradientStyles.Solid;
065.
DrawBorder =
true
;
066.
DrawFill =
true
;
067.
BackColor = Color.FromArgb(255, 230, 238, 254);
068.
GradientStyle = GradientStyles.Solid;
069.
}
070.
071.
public
override
void
Synchronize()
072.
{
073.
base
.Synchronize();
074.
Text =
string
.Empty;
075.
if
(Data.DataBoundItem
is
not NotificationB n)
return
;
076.
notificationTitleElement.Text = Convert.ToString(n.Degree);
077.
}
078.
}
079.
080.
public
partial
class
TestForm : RadForm {
081.
public
TestForm() {
082.
InitializeComponent();
083.
InitializeViewAppearance();
084.
}
085.
086.
private
void
InitializeViewAppearance() {
087.
var notifications =
new
List<INotification> {
088.
new
NotificationA {Name =
"Foo"
},
089.
new
NotificationA {Name =
"Bar"
},
090.
new
NotificationB { Degree = 180 }
091.
};
092.
for
(var i = 0; i < 100000; i++) {
093.
notifications.Add(
new
NotificationA { Name = $
"test item {i}"
});
094.
}
095.
lcNotifications.CreatingVisualListItem += OnNotificationItemCreating;
096.
lcNotifications.DataSource = notifications;
097.
}
098.
099.
private
void
OnNotificationItemCreating(
object
sender, CreatingVisualListItemEventArgs args)
100.
{
101.
args.VisualItem = args.DataItem.DataBoundItem
switch
{
102.
NotificationA _ =>
new
NotificationAListItem(),
103.
NotificationB _ =>
new
NotificationBListItem(),
104.
_ => args.VisualItem
105.
};
106.
}
107.
}
I've created a custom cell in a GridView with two labels. It works so long as the grid isn't resized or the number of rows do not exceed the length of the grid. When either of the two occur the custom cells can loose their formatting and cells without formatting adopt traits from the custom formatting.
This snippet demonstrates the issue.
A bump in the right direction would be appreciated.
using
System;
using
System.Collections.Generic;
using
System.Drawing;
using
System.Windows.Forms;
using
Telerik.WinControls.Layouts;
using
Telerik.WinControls.UI;
namespace
TR_Test
{
public
partial
class
GridTest : Telerik.WinControls.UI.RadForm
{
public
GridTest()
{
InitializeComponent();
//simple grid
this
.radGridView1.CreateCell +=
new
Telerik.WinControls.UI.GridViewCreateCellEventHandler(
this
.radGridView1_CreateCell);
this
.radGridView1.AllowAddNewRow =
false
;
this
.radGridView1.AllowSearchRow =
false
;
this
.radGridView1.ShowGroupPanel =
false
;
this
.radGridView1.ShowRowHeaderColumn =
false
;
this
.radGridView1.TableElement.RowHeight = 60;
// Populate the grid with data
PopulateGrid();
radGridView1.Columns[
"Info"
].Width = 150;
}
private
void
PopulateGrid()
{
List<Sales> myList =
new
List<Sales>();
myList.Add(
new
Sales(1,
"Outdoor,1111"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(2,
"Hardware,2222"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(3,
"Tools,3333"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(4,
"Books,4444"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(5,
"Shows,5555"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(6,
"Mugs,6666"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(7,
"Phones,7777"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(8,
"Indore,8888"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(9,
"Cats,9999"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(10,
"Dogs,0000"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(11,
"Outdoor,1111"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(12,
"Hardware,2222"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(13,
"Tools,3333"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(14,
"Books,4444"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(15,
"Shows,5555"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(16,
"Mugs,6666"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(17,
"Phones,7777"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(18,
"Indore,8888"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(19,
"Cats,9999"
,
"asdf"
,
"asdf"
));
myList.Add(
new
Sales(20,
"Dogs,0000"
,
"asdf"
,
"asdf"
));
radGridView1.BindingContext =
new
BindingContext();
radGridView1.DataSource = myList;
}
private
void
radGridView1_CreateCell(
object
sender, Telerik.WinControls.UI.GridViewCreateCellEventArgs e)
{
if
(e.CellType ==
typeof
(GridDataCellElement))
{
GridViewDataColumn dataColumn = e.Column
as
GridViewDataColumn;
switch
(dataColumn.Name)
{
case
"Info"
:
e.CellType =
typeof
(SplitCell);
break
;
}
}
}
}
public
class
SplitCell : GridDataCellElement
{
private
StackLayoutPanel panel;
private
RadLabelElement label1;
private
RadLabelElement label2;
public
SplitCell(GridViewColumn column, GridRowElement row) :
base
(column, row)
{ }
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.panel =
new
StackLayoutPanel
{
Margin =
new
System.Windows.Forms.Padding(5),
Orientation = System.Windows.Forms.Orientation.Vertical
};
this
.label1 =
new
RadLabelElement
{
Font =
new
Font(
"Segoe UI"
, 16.0f)
};
this
.panel.Children.Add(
this
.label1);
this
.label2 =
new
RadLabelElement
{
Font =
new
Font(
"Segoe UI"
, 9.0f)
};
this
.panel.Children.Add(
this
.label2);
this
.Children.Add(
this
.panel);
}
protected
override
void
SetContentCore(
object
value)
{
object
cellValue = value;
this
.label1.Text =
""
;
this
.label2.Text =
""
;
if
(cellValue
is
DBNull || cellValue ==
null
)
cellValue =
","
;
string
[] s = cellValue.ToString().Split(
','
);
if
(s.Length >= 1)
this
.label1.Text = s[0];
if
(s.Length >= 2)
this
.label2.Text = s[1];
}
}
public
class
Sales
{
public
Sales(
int
id,
string
info,
string
PO,
string
Paid)
{
this
.ID = id;
this
.Info = info;
this
.PO = PO;
this
.Paid = Paid;
}
public
int
ID {
get
;
set
; }
public
string
Info {
get
;
set
; }
public
string
PO {
get
;
set
; }
public
string
Paid {
get
;
set
; }
}
}
Hello,
When using a VisualStudio2012Dark themed GridView with ColumnHeader, GroupPanel, and AddNewRow turned off, the top border of the grid is missing. It only appears with a border width that is greater than 1.
To reproduce:
RadGridView1.ShowColumnHeaders =
False
RadGridView1.ShowGroupPanel =
False
RadGridView1.AllowAddNewRow =
False
RadGridView1.Columns.Add(
"1"
)
RadGridView1.Columns.Add(
"2"
)
RadGridView1.Columns.Add(
"3"
)
RadGridView1.Rows.Add(1, 2, 3)
RadGridView1.Rows.Add(4, 5, 6)
RadGridView1.CurrentRow =
Nothing
RadGridView1.TableElement.DrawBorder =
True
RadGridView1.TableElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder
RadGridView1.TableElement.BorderGradientStyle = Telerik.WinControls.GradientStyles.Solid
RadGridView1.TableElement.BorderColor = Color.Yellow
RadGridView1.TableElement.BorderWidth = 1
I'm not sure if that is part of the theme, but either way I can't seem to add a single pixel border to the top.
Also, the description for TableElement.BorderWidth is incorrect; it says it is for the left border.
This is for R3 2018.
hi
i can change font FilterPopup but font "available filers" not changes
This section is marked in the photo below
hi
i tranaslte all word in grid but "filter dialog" not ranslates
This section is marked in the photo below
Hello
I am trying to write a customEditor for a gridview to handle "rapid" data entry for grade values.
The grade values can be from 0 to 10 in steps of 0.5 (valid values are, for instance, 4 or 4.5, but not 4.1)
I wish to be able to type in the grades on the numerical keypad and on the main keyboard
where:typing a single character numeric value sets the value typed
and typing CTRL-num value sets the "halfed grade" (ex: type CTRL-4 for obtaining 4.5)
furthermoreI need to have the cursor positioned to the cell below imediately after the entry validation
The columns are currently text columns but could be numerical columns
I have tried using the followind code and Custom Editor:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Private Sub gvMark_EditorRequired(sender As Object, e As EditorRequiredEventArgs) Handles gvMark.EditorRequired
If e.EditorType Is GetType(RadTextBoxEditor) Then
e.EditorType = GetType(MarkEditor)
End If
End Sub
Public Class MarkEditor
Inherits RadTextBoxEditor
Public Property Value As Object
Get
Dim Editor As RadTextBoxEditorElement = CType(EditorElement, RadTextBoxEditorElement)
Return Editor.Text
End Get
Set(value As Object)
Dim Editor As RadTextBoxEditorElement = CType(EditorElement, RadTextBoxEditorElement)
If value IsNot Nothing Then
Editor.Text = Convert.ToString(value)
Else
Editor.Text = ""
End If
End Set
End Property
Public Overrides Sub BeginEdit()
MyBase.BeginEdit()
Me.EditorElement.Focus()
Dim EditorElement As RadTextBoxEditorElement = CType(Me.EditorElement, RadTextBoxEditorElement)
AddHandler EditorElement.KeyDown, AddressOf Element_KeyDown
End Sub
Public Overrides Function EndEdit() As Boolean
MyBase.EndEdit()
Me.EditorElement.Focus()
Dim EditorElement As RadTextBoxEditorElement = CType(Me.EditorElement, RadTextBoxEditorElement)
RemoveHandler EditorElement.KeyDown, AddressOf Element_KeyDown
Return MyBase.EndEdit
End Function
Private Sub Element_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
Try
Dim KeyChar As String = fromKeyCode(e.KeyCode)
If Not e.Control Then
Value = KeyChar
Else
Value = KeyChar & ".5"
End If
Catch ex As Exception
End Try
End Sub
Public Function fromKeyCode(KeyCode As Integer) As String
'returns the caracters 0..9 for Keyboard Keys 0..9 and NumPadKeys 0..9 and "*" from NumPad "Multiply"
Try
If KeyCode >= 48 And KeyCode <= 57 Then '0..9 Keyboard
Return (KeyCode - 48)
ElseIf KeyCode >= 96 And KeyCode <= 105 Then '0..9 NumPad
Return (KeyCode - 96)
ElseIf KeyCode = 106 Then '* NumPad
Return "*"
Else
Return ""
End If
Catch ex As Exception
Return ""
End Try
End Function
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have a strange result (same result when using the keyboard or the numeric pad)
1. if I type a single numeric value -> it is displayed twice in the cell, i.e.if I type 4 I see 44 and the cursor is in the middle of the two characters
2. if I type CTRL-4 I get the desired 4.5 string in the cell
3. I have tried to add a sendkeys.send(vbcr) at different places (valueChanged, CellvalueChanged events unsuccessfully) to move the focus to the cell below
(Ultimately I'll have to do more advanced data validation based on other criterias)
Thanks in advance for any suggestion
Best Regards