|
Query |
Solution | ||
|
Hide rectangle while click on cell, when i click on cell it is showing current cell selected but my requirement is display row as selected & don't want to display cell selected. |
This can be achieved by setting SfDataGrid.NavigationMode as Row. Please refer to the following code example.
Code Example:
| ||
|
On Page Load 1st row for 1st group should be by default selected. |
You can move the selection to any row on page load by using the SfDataGrid.MoveToCurrentCell method within the Form.Load event.
Please refer to the following code example.
Code example :
| ||
|
Don't want to show expand column for groups, as i have all the groups expanded by default, also group should not be collapsed. |
To hide the indent column set the SfDataGrid.IndentColumnWidth property to 0 before grouping a column. Please refer to the following code example.
Code Example :
Collapsing and expanding the group can be avoided by using SfDataGrid.GroupExpanding and SfDataGrid.GroupCollapsing events. Please refer to the following code example.
UG Links :
| ||
|
TableSummaryRow X location to changed to same as GroupSummary Row. (i e. If i have group summary for 3rd column Then TableSummaryRow should be displayed
in 3rd Column ) |
You can achieve this by adding the group summary and table summary for the same column. Please refer to the following code example.
Code Example :
| ||
|
When moving through grid don't want TableSummaryRow , GroupSummaryRow OR CaptionSummaryRow to selected(ie. From last row of Group(expect
GroupSummaryRow ) selection should move to next group first row.) |
This can also be achieved by using the SfDataGrid.MoveToCurrentCell method within the SfDataGrid.SelectionChanging event. Please refer to the following code example.
Code Example :
| ||
|
Require CaptionSummaryRow {Key}value For Group in GroupSummaryRow |
This can be achieved by changing the display text of the GroupSummary within the SfDataGrid.DrawCell event. Please refer to the following code example.
Code Example:
|
|
public Form1()
{
InitializeComponent();
this.sfDataGrid.SelectionController = new CustomRowSelectionController(this.sfDataGrid);
}
public class CustomRowSelectionController : RowSelectionController
{
SfDataGrid DataGrid;
public CustomRowSelectionController(SfDataGrid sfDataGrid)
: base(sfDataGrid)
{
this.DataGrid = sfDataGrid;
}
protected override void ProcessArrowKeysForSingleMultipleSelection(KeyEventArgs args)
{
if (args.KeyCode == Keys.Up)
{
this.DataGrid.MoveToCurrentCell(new RowColumnIndex(this.GetPreviousRecordRowIndex(this.DataGrid.CurrentCell.RowIndex), this.DataGrid.CurrentCell.ColumnIndex));
}
else if (args.KeyCode == Keys.Down)
{
this.DataGrid.MoveToCurrentCell(new RowColumnIndex(this.GetNextRecordRowIndex(this.DataGrid.CurrentCell.RowIndex), this.DataGrid.CurrentCell.ColumnIndex));
}
else
base.ProcessArrowKeysForSingleMultipleSelection(args);
}
bool IsCaptionSummaryRow(int rowIndex)
{
var startIndex = this.DataGrid.TableControl.ResolveStartIndexBasedOnPosition();
var record = this.DataGrid.View.TopLevelGroup.DisplayElements[rowIndex - startIndex];
return record != null && record is Group;
}
bool IsGroupSummaryRow(int rowIndex)
{
var startIndex = this.DataGrid.TableControl.ResolveStartIndexBasedOnPosition();
var record = this.DataGrid.View.TopLevelGroup.DisplayElements[rowIndex - startIndex];
return record != null && record is SummaryRecordEntry;
}
private int GetNextRecordRowIndex(int currentRowIndex)
{
int nextRecordRowIndex = currentRowIndex + 1;
if (nextRecordRowIndex > this.GetLastRowIndex(this.DataGrid))
return this.DataGrid.CurrentCell.RowIndex;
if (!this.IsCaptionSummaryRow(nextRecordRowIndex) && !this.IsGroupSummaryRow(nextRecordRowIndex))
return nextRecordRowIndex;
else
return GetNextRecordRowIndex(nextRecordRowIndex);
}
private int GetLastRowIndex(SfDataGrid dataGrid)
{
if (dataGrid.View.Records.Count == 0)
return -1;
var footerCount = dataGrid.GetUnboundRowsCount(VerticalPosition.Bottom, true);
int count = 0;
int index = dataGrid.RowCount - (dataGrid.TableControl.GetTableSummaryCount(VerticalPosition.Bottom) + footerCount + 1);
for (int start = index; start >= 0; start--)
{
if (!dataGrid.TableControl.RowHeights.GetHidden(start, out count))
return start;
}
return index;
}
private int GetPreviousRecordRowIndex(int currentRowIndex)
{
int previousRecordRowIndex = currentRowIndex - 1;
if (previousRecordRowIndex <= 0)
return this.DataGrid.CurrentCell.RowIndex;
if (!this.IsCaptionSummaryRow(previousRecordRowIndex) && !this.IsGroupSummaryRow(previousRecordRowIndex))
return previousRecordRowIndex;
else
return GetPreviousRecordRowIndex(previousRecordRowIndex);
}
} |
|
protected override void HandleKeyOperations(KeyEventArgs args)
{
if(args.KeyCode == Keys.Enter)
{
KeyEventArgs arguments = new KeyEventArgs(Keys.Down);
base.HandleKeyOperations(arguments);
args.Handled = arguments.Handled;
return;
}
base.HandleKeyOperations(args);
} |
|
protected override void HandlePointerOperations(Syncfusion.WinForms.DataGrid.Events.DataGridPointerEventArgs args, RowColumnIndex rowColumnIndex)
{
if (this.IsCaptionSummaryRow(rowColumnIndex.RowIndex) || this.IsGroupSummaryRow(rowColumnIndex.RowIndex))
return;
base.HandlePointerOperations(args, rowColumnIndex);
} |
|
Query |
Solution | |
|
Is there any way to hide or remove icon from IndentColumn(expand or collapse icon for groups) |
Currently we don’t have support to customize the expand/collapse icon in the group caption. We don’t have any immediate plans to implement. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented. | |
|
Need IndentColumn for Group which has another group, IndentColumn should not be displayed for group which has not reocrds |
You can achieve this by setting the width of the indent column to 0 by default and change it to 28 only when the SfDataGrid.GroupColumnDescriptions count is greater than 1. Please refer the following code example and sample from the following link.
Code example :
Please let us know if the given solution doesn’t meet your requirement.
|
|
public Form1()
{
InitializeComponent();
this.sfDataGrid.SelectionController = new CustomRowSelectionController(this.sfDataGrid);
}
public class CustomRowSelectionController : RowSelectionController
{
SfDataGrid DataGrid;
public CustomRowSelectionController(SfDataGrid sfDataGrid)
: base(sfDataGrid)
{
this.DataGrid = sfDataGrid;
}
protected override void HandlePointerOperations(Syncfusion.WinForms.DataGrid.Events.DataGridPointerEventArgs args, RowColumnIndex rowColumnIndex)
{
if (this.IsCaptionSummaryRow(rowColumnIndex.RowIndex) || this.IsGroupSummaryRow(rowColumnIndex.RowIndex))
return;
base.HandlePointerOperations(args, rowColumnIndex);
}
protected override void HandleKeyOperations(KeyEventArgs args)
{
if (args.KeyCode == Keys.Enter)
{
KeyEventArgs arguments = new KeyEventArgs(Keys.Down);
base.HandleKeyOperations(arguments);
args.Handled = arguments.Handled;
return;
}
base.HandleKeyOperations(args);
}
protected override void ProcessArrowKeysForSingleMultipleSelection(KeyEventArgs args)
{
if (args.KeyCode == Keys.Up)
{
this.DataGrid.MoveToCurrentCell(new RowColumnIndex(this.GetPreviousRecordRowIndex(this.DataGrid.CurrentCell.RowIndex), this.DataGrid.CurrentCell.ColumnIndex));
}
else if (args.KeyCode == Keys.Down)
{
this.DataGrid.MoveToCurrentCell(new RowColumnIndex(this.GetNextRecordRowIndex(this.DataGrid.CurrentCell.RowIndex), this.DataGrid.CurrentCell.ColumnIndex));
}
else
base.ProcessArrowKeysForSingleMultipleSelection(args);
}
bool IsCaptionSummaryRow(int rowIndex)
{
var startIndex = this.DataGrid.TableControl.ResolveStartIndexBasedOnPosition();
var record = this.DataGrid.View.TopLevelGroup.DisplayElements[rowIndex - startIndex];
return record != null && record is Group;
}
bool IsGroupSummaryRow(int rowIndex)
{
var startIndex = this.DataGrid.TableControl.ResolveStartIndexBasedOnPosition();
var record = this.DataGrid.View.TopLevelGroup.DisplayElements[rowIndex - startIndex];
return record != null && record is SummaryRecordEntry;
}
private int GetNextRecordRowIndex(int currentRowIndex)
{
int nextRecordRowIndex = currentRowIndex + 1;
if (nextRecordRowIndex > this.GetLastRowIndex(this.DataGrid))
{
this.DataGrid.TableControl.VerticalScroll.Value = this.DataGrid.TableControl.VerticalScroll.Maximum;
return this.DataGrid.CurrentCell.RowIndex;
}
if (!this.IsCaptionSummaryRow(nextRecordRowIndex) && !this.IsGroupSummaryRow(nextRecordRowIndex))
return nextRecordRowIndex;
else
return GetNextRecordRowIndex(nextRecordRowIndex);
}
private int GetLastRowIndex(SfDataGrid dataGrid)
{
if (dataGrid.View.Records.Count == 0)
return -1;
var footerCount = dataGrid.GetUnboundRowsCount(VerticalPosition.Bottom, true);
int count = 0;
int index = dataGrid.RowCount - (dataGrid.TableControl.GetTableSummaryCount(VerticalPosition.Bottom) + footerCount + 1);
for (int start = index; start >= 0; start--)
{
if (!dataGrid.TableControl.RowHeights.GetHidden(start, out count))
return start;
}
return index;
}
private int GetPreviousRecordRowIndex(int currentRowIndex)
{
int previousRecordRowIndex = currentRowIndex - 1;
if (previousRecordRowIndex <= 0)
{
this.DataGrid.TableControl.VerticalScroll.Value = this.DataGrid.TableControl.VerticalScroll.Minimum;
return this.DataGrid.CurrentCell.RowIndex;
}
if (!this.IsCaptionSummaryRow(previousRecordRowIndex) && !this.IsGroupSummaryRow(previousRecordRowIndex))
return previousRecordRowIndex;
else
return GetPreviousRecordRowIndex(previousRecordRowIndex);
}
} |