To reproduce:
DataTable t = new DataTable();
t.Columns.Add("timeSpan", typeof(TimeSpan));
t.Rows.Add(TimeSpan.FromHours(11));
t.Rows.Add(TimeSpan.FromHours(2));
t.Rows.Add(TimeSpan.FromHours(4));
t.Rows.Add(TimeSpan.FromMinutes(17));
radGridView1.DataSource = t;
GridViewSummaryItem summaryItem = new GridViewSummaryItem();
summaryItem.Name = "timeSpan";
summaryItem.Aggregate = GridAggregateFunction.Sum;
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
Workaround:
CustomSummaryItem summaryItem = new CustomSummaryItem("timeSpan", "", GridAggregateFunction.Sum);
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
summaryRowItem.Add(summaryItem);
this.radGridView1.SummaryRowsTop.Add(summaryRowItem);
public class CustomSummaryItem : GridViewSummaryItem
{
public CustomSummaryItem(string name, string formatString, GridAggregateFunction aggregate)
: base(name, formatString, aggregate)
{ }
public override object Evaluate(IHierarchicalRow row)
{
TimeSpan timeSpanSum = new TimeSpan();
foreach (GridViewRowInfo childRow in row.ChildRows)
{
timeSpanSum += (TimeSpan)childRow.Cells["timeSpan"].Value;
}
return timeSpanSum;
}
}
Use the following code snippet:
public Form1()
{
InitializeComponent();
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Id");
radGridView1.MasterTemplate.Columns.Add(decimalColumn);
GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Name");
radGridView1.MasterTemplate.Columns.Add(textBoxColumn);
GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("CreatedOn");
radGridView1.MasterTemplate.Columns.Add(dateTimeColumn);
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
for (int i = 0; i < 10; i++)
{
radGridView1.Rows.Add(i, "Name" + i, DateTime.Now.AddDays(i));
}
radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Disable;
}
If you copy a cell content and try to paste it to another cell of the same column, the content is pasted successfully, although the ClipboardPasteMode property is set to Disable.
The check box should be placed in the header cell (if the users wants to). Additionally it should be able to control both one level and hierarchy Resolution: You need to set the EnableHeaderCheckBox property to true. Please refer in help article for more information: http://www.telerik.com/help/winforms/gridview-columns-gridviewcheckboxcolumn.html
To reproduce: - Add the following column to a blank grid and new row or edit the existing one: GridViewMaskBoxColumn maskBoxColumn = new GridViewMaskBoxColumn(); maskBoxColumn.Name = "Dates"; maskBoxColumn.HeaderText = "Dates"; maskBoxColumn.MaskType = MaskType.FreeFormDateTime; maskBoxColumn.DataType = typeof(System.DateTime); radGridView1.MasterTemplate.Columns.Add(maskBoxColumn); this.radGridView1.Rows.Add(DateTime.Now.AddDays(5));
Sort capabilities in column chooser form.
The Column Chooser of RadGridView should show the invisible columns sorted.
To reproduce:
Private _createDataTable As Object
Private _BoxValue As String
Sub New()
InitializeComponent()
RelCalculateValues()
Me.RadGridView1.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells)
End Sub
Private Sub RadGridView1_CellEndEdit(sender As Object, e As GridViewCellEventArgs) _
Handles RadGridView1.CellEndEdit
If e.RowIndex < 0 OrElse e.ColumnIndex < 0 Then Exit Sub
If e.Value = _BoxValue Then Exit Sub
If e.Column.Name <> "AllowedWane" Then Exit Sub
Dim fTester As Decimal
Dim rRow As Telerik.WinControls.UI.GridViewDataRowInfo = e.Row
Dim iRowID As Int32
iRowID = rRow.Cells("ID").Value
If iRowID < 0 Then Exit Sub
Select Case e.Column.Name
Case "AllowedWane"
If Decimal.TryParse(e.Value, fTester) = False Then
rRow.Cells(e.Column.Name).Value = _BoxValue
Exit Sub
Else
Select Case e.Column.OwnerTemplate.MasterTemplate.Owner.Name
Case RadGridView1.Name
RelCalculateValues(Me.RadGridView1)
End Select
End If
End Select
End Sub
Private Sub RelCalculateValues(ByVal rgvAsete As Telerik.WinControls.UI.RadGridView)
Dim dtJakauma As New DataTable
Dim drJakauma As DataRow
dtJakauma.Columns.Add("ID", GetType(Int32))
dtJakauma.Columns.Add("Dimensions", GetType(String))
dtJakauma.Columns.Add("Pcs", GetType(String))
dtJakauma.Columns.Add("Percents", GetType(String))
dtJakauma.Columns.Add("Price", GetType(String))
dtJakauma.Columns.Add("UsageFactor", GetType(String))
dtJakauma.Columns.Add("CubicMeters", GetType(String))
dtJakauma.Columns.Add("EdgeLimit", GetType(String))
dtJakauma.Columns.Add("AllowedWane", GetType(String))
dtJakauma.Columns.Add("Length", GetType(String))
For i As Int32 = 0 To 5
drJakauma = dtJakauma.NewRow
drJakauma("ID") = 0
drJakauma("Dimensions") = "Dimensions_" & i
drJakauma("Pcs") = "Pcs_" & i
drJakauma("Percents") = "Percents_" & i
drJakauma("Price") = "Price_" & i
drJakauma("UsageFactor") = "UsageFactor_" & i
drJakauma("CubicMeters") = "CubicMeters_" & i
drJakauma("EdgeLimit") = "EdgeLimit_" & i
drJakauma("AllowedWane") = "AllowedWane_" & i
drJakauma("Length") = "Length_" & i
dtJakauma.Rows.Add(drJakauma)
Next
rgvAsete.DataSource = dtJakauma
rgvAsete.BestFitColumns(Telerik.WinControls.UI.BestFitColumnMode.AllCells)
End Sub
Workaround: set the RadGridView.DataSource to null/Nothing before setting it to the new DataTable.
To reproduce set AddNewRowPosition is Bottom and the NewRowEnterKeyMode is EnterMovesToNextCell and add a new row via na UI
Workaround:
void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add && radGridView1.CurrentRow is GridViewNewRowInfo)
{
}
}
To reproduce:
1. Add a RadGridView and a RadButton.
2. Enable paging.
3. Use the code snippet below:
private void Form1_Load(object sender, EventArgs e)
{
this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
bs.DataSource = this.ordersBindingSource;
this.radGridView1.DataSource = bs;
}
BindingSource bs = new BindingSource();
private void radButton1_Click(object sender, EventArgs e)
{
bs.Filter ="ShipName LIKE '%z%'";
}
4. Navigate to page 80 and click the button.
5. You have only 4 pages available , but you are still positioned on page 80.
Workaround:
private void radButton1_Click(object sender, EventArgs e)
{
bs.Filter ="ShipName LIKE '%z%'";
if (this.radGridView1.MasterTemplate.PageIndex>this.radGridView1.MasterTemplate.TotalPages)
{
this.radGridView1.MasterTemplate.MoveToFirstPage();
}
}
To reproduce: Add a RadGridView with some data and enable the paging functionality. Also set the AutoSize property to true: grid.EnablePaging = true; grid.AutoSize = true; Start the application and you will see that when you try to edit the textbox with the number of the page you will not be able to. Workaround: Set the AutoSize property to false and use MinimumSize instead: grid.AutoSize = false; grid.MinimumSize = new Size(600, 500);
To reproduce:
DataTable dt = new DataTable();
public Form1()
{
InitializeComponent();
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Title", typeof(string));
dt.Columns.Add("ParentID", typeof(int));
for (int i = 1; i <= 5; i++)
{
dt.Rows.Add(i, "Parent." + i, 0);
}
Random rand = new Random();
for (int i = 6; i < 20; i++)
{
dt.Rows.Add(i, "Child." + i, rand.Next(1, 6));
}
for (int i = 20; i < 40; i++)
{
dt.Rows.Add(i, "SubChild." + i, rand.Next(6, 20));
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}
Customize the default DateTime filtering in order to allow scenarios, when the end users enters both date and time part, or only time and filter is applied based on the chosen criteria.
To reproduce:
Create a self reference RadGridView and add enough columns so that a horizontal scrollbar appears. Scroll the horizontal scrollbar to the right and close the form. You will see an exception.
Workaround:
Create a custom row element in the CreateRow event:
void radGridView1_CreateRow(object sender, Telerik.WinControls.UI.GridViewCreateRowEventArgs e)
{
if (e.RowInfo is GridViewHierarchyRowInfo || e.RowInfo is GridViewDataRowInfo)
{
e.RowElement = new MyDataRowElement();
}
}
public class MyLayout : SelfReferenceCellLayout
{
public MyLayout(GridRowElement rowElement) : base(rowElement) { }
public override void DetachCellElements()
{
if (this.StackLayoutElement != null)
{
base.DetachCellElements();
}
}
}
public class MyDataRowElement : GridDataRowElement
{
private MyLayout cellReferenceLayout;
public override void Detach()
{
base.Detach();
if (this.cellReferenceLayout != null)
{
this.cellReferenceLayout.DetachCellElements();
}
}
protected override void DisposeManagedResources()
{
if (this.cellReferenceLayout != null)
{
this.cellReferenceLayout.Dispose();
}
base.DisposeManagedResources();
}
public override SelfReferenceCellLayout SelfReferenceLayout
{
get
{
if (this.RowInfo is GridViewHierarchyRowInfo)
{
if (this.ViewTemplate != null &&
this.ViewTemplate.IsSelfReference &&
this.cellReferenceLayout == null)
{
this.cellReferenceLayout = new MyLayout(this);
}
return this.cellReferenceLayout;
}
return null;
}
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridDataRowElement);
}
}
}
To reproduce:
public Form1()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
this.radGridView1.Columns.Add("Col" + i);
}
for (int i = 0; i < 8000; i++)
{
GridViewRowInfo row = radGridView1.Rows.NewRow();
foreach (GridViewCellInfo cell in row.Cells)
{
cell.Value = "Data" + row.Index + "." + cell.ColumnInfo.Index;
}
radGridView1.Rows.Add(row);
}
GridViewTemplate childTemplate = CreateChildTemplate();
this.radGridView1.Templates.Add(childTemplate);
childTemplate.HierarchyDataProvider = new GridViewEventDataProvider(childTemplate);
this.radGridView1.RowSourceNeeded += radGridView1_RowSourceNeeded;
}
private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
{
for (int i = 0; i < 10; i++)
{
GridViewRowInfo row = e.Template.Rows.NewRow();
row.Cells["Name"].Value = "Name" + i;
row.Cells["ProductNumber"].Value = "ProductNumber" + i;
e.SourceCollection.Add(row);
}
}
private GridViewTemplate CreateChildTemplate()
{
GridViewTemplate template = new GridViewTemplate();
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewTextBoxColumn namecolumn = new GridViewTextBoxColumn("Name");
GridViewTextBoxColumn productNumberColumn = new GridViewTextBoxColumn("ProductNumber");
template.Columns.AddRange(namecolumn,
productNumberColumn);
return template;
}
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.GridNavigator.SelectLastRow();
}
Workaround: navigate the vertical scrollbar to the last row before calling the SelectLastRow method:
private void radButton1_Click(object sender, EventArgs e)
{
this.radGridView1.TableElement.RowScroller.Scrollbar.PerformLast();
this.radGridView1.GridNavigator.SelectLastRow();
}
To reproduce: - Add some rows to a grid view and set the ClipboardCopyMode to EnableAlwaysIncludeHeaderText. - Copy entire row and paste it in excel. You will notice that the columns are pasted right, but the cells values are merged. - Also when multiple rows are copied the issue does not occur.
To reproduce:
Use the code snippet below:
static DataSet ds;
public form1()
{
InitializeComponent();
GridviewStyling(radGridView1);
ds = PrepareDataset();
BuildGrid();
//Set_Hierarchy();
for (int i = 0; i < radGridView1.Templates.Count; i++)
GridviewTemplateStyling(radGridView1.Templates[i]);
this.radGridView1.TableElement.PageViewMode = PageViewMode.ExplorerBar;
this.radGridView1.ViewCellFormatting += radGridView1_ViewCellFormatting;
}
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
if (detailCell != null)
{
GridViewHierarchyRowInfo hierarchyRow = (GridViewHierarchyRowInfo)((GridViewDetailsRowInfo)detailCell.RowInfo).Owner;
detailCell.PageViewElement.Header.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
RadPageViewElement el = detailCell.PageViewElement as RadPageViewExplorerBarElement;
if (el != null)
{
for (int i = 0; i < el.Items.Count; i++) // detailCell.PageViewElement.Items.Count
{
RadPageViewItem item = detailCell.PageViewElement.Items[i];
GridViewInfo viewInfo = hierarchyRow.Views[i];
item.MaxSize = new Size(0, 1);
item.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
if (viewInfo.ChildRows.Count != 0)
{
item.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
}
}
}
}
}
private DataSet PrepareDataset()
{
Random r = new Random();
DataSet ds = new DataSet("DS");
//snir
DataTable dtFirst = new DataTable("Snir");
dtFirst.Columns.Add("pId", typeof(int));
dtFirst.Columns.Add("Col1", typeof(int));
dtFirst.Columns.Add("Col", typeof(string));
dtFirst.Columns.Add("Col3", typeof(int));
dtFirst.Columns.Add("Col4", typeof(string));
for (int i = 0; i < 5; i++)
dtFirst.Rows.Add(1, i, "snirsnirsnir" + r.Next(0, 100).ToString(),
r.Next(0, 35), "snir" + r.Next(0, 100).ToString());
// jenny
DataTable dtSecond = new DataTable("Jenny");
dtSecond.Columns.Add("pId", typeof(int));
dtSecond.Columns.Add("Col1", typeof(int));
dtSecond.Columns.Add("Col2", typeof(string));
dtSecond.Columns.Add("Col3", typeof(int));
dtSecond.Columns.Add("Col4", typeof(string));
dtSecond.Columns.Add("Col5", typeof(string));
dtSecond.Columns.Add("Col6", typeof(string));
for (int i = 0; i < 5; i++)
dtSecond.Rows.Add(2, i, "CnC" + r.Next(0, 100).ToString(),
r.Next(0, 35), "jenny" + r.Next(0, 100).ToString(), "col5", "col6");
//index
DataTable table1 = new DataTable("Index");
table1.Columns.Add("TableId", typeof(int));
table1.Columns.Add("TableName", typeof(string));
table1.Columns.Add("UpdateType", typeof(int));
table1.Rows.Add(1, dtFirst.TableName, r.Next(0, 3));
table1.Rows.Add(2, dtSecond.TableName, r.Next(0, 3));
ds.Tables.AddRange(new DataTable[] { table1, dtFirst, dtSecond });
return ds;
}
private void BuildGrid()
{
// bind the master template
this.radGridView1.DataSource = ds;
this.radGridView1.DataMember = "Index";
//templates
GridViewTemplate template1 = new GridViewTemplate();
template1.DataSource = ds.Tables[1];
template1.Columns[0].IsVisible = false;
template1.EnableHierarchyFiltering = false;
template1.ShowGroupedColumns = false;
radGridView1.Templates.Add(template1);
GridViewTemplate template2 = new GridViewTemplate();
template2.DataSource = ds.Tables[2]; // 1:snir // 2:jenny
radGridView1.Templates.Add(template2);
template1.AllowDragToGroup = false;
//relations
GridViewRelation relation1 = new GridViewRelation(radGridView1.MasterTemplate);//, template2);
relation1.RelationName = "myRelation1";
relation1.ChildTemplate = radGridView1.Templates[0];
relation1.ChildColumnNames.AddRange(new string[] { "pId" });
relation1.ParentColumnNames.Add("TableId");
radGridView1.Relations.Add(relation1);
GridViewRelation relation2 = new GridViewRelation(radGridView1.MasterTemplate);//, template2);
relation2.RelationName = "myRelation2";
relation2.ChildTemplate = radGridView1.Templates[1];
relation2.ChildColumnNames.AddRange(new string[] { "pId" });
relation2.ParentColumnNames.Add("TableId");
radGridView1.Relations.Add(relation2);
}
private void GridviewStyling(RadGridView rgv)
{
//radGridView1 styling
rgv.AllowAddNewRow = false;
rgv.EnableGrouping = false;
rgv.AllowDragToGroup = false;
rgv.AllowDrop = false;
rgv.AllowEditRow = false;
rgv.AllowDrop = false;
rgv.AllowRowResize = false;
rgv.AllowColumnResize = false;
rgv.AutoExpandGroups = true;
rgv.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
rgv.EnableCustomGrouping = false;
rgv.ShowColumnHeaders = true;
rgv.ShowRowHeaderColumn = false;
rgv.ShowGroupPanel = false;
}
private void GridviewTemplateStyling(GridViewTemplate gvt)
{
//template styling
gvt.AllowAddNewRow = false;
gvt.Columns[0].IsVisible = false;
gvt.ShowChildViewCaptions = false;
gvt.AllowDragToGroup = false;
gvt.AllowRowResize = false;
gvt.AllowColumnResize = false;
gvt.AutoExpandGroups = true;
gvt.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
gvt.ShowRowHeaderColumn = false;
gvt.ShowColumnHeaders = true;
}
private string GetEnumString(int n)
{
switch (n)
{
case (int)TableUpdateModeEnum.INSERT:
return "INSERT";
case (int)TableUpdateModeEnum.UPDATE:
return "UPDATE";
case (int)TableUpdateModeEnum.UPDATE_OR_INSERT:
return "UPDATE/DELETE";
case (int)TableUpdateModeEnum.DELETE_OR_INSERT:
return "INSERT/DELETE";
default:
return "";
}
}
public enum TableUpdateModeEnum
{
[Description("Snir")]
INSERT = 0,
[Description("Liraz")]
UPDATE_OR_INSERT = 1,
[Description("Jenny")]
UPDATE = 2,
[Description("Tsuria")]
DELETE_OR_INSERT = 3
};
Scenario:
1.Expand a master row.
2.Start dragging columns from the child template.
3.When your are dragging over the thick border , the exception occur.
Add similar like DateColumn.DateTimeMode property for GridViewDateTimeColumn. Link in MSDN: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.datetimemode.aspx
The issue may be releated to measure layout logic. Ticked ID: 381352 One thing more I noticed. Actually I do not think, this issue is a sorting issue, but rather some rendering issue, where the old version is much faster than the new one. If you compare the scrolling performance between the new and the old version, also here the old version is significantly faster. So I think this is a more general issue, something with the rendering - or what you call it - of the visible part of the grid, which are faster in the old version. Am I the only customer noticing this ?
Resolution: Individual cells cannot have specific FormatString since the property is bound to column's FormatString