BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
this.datagrid.SelectionController = new GridSelectionControllerExt(datagrid);
public class GridSelectionControllerExt : GridSelectionController
{
SfDataGrid datagrid;
public GridSelectionControllerExt(SfDataGrid dataGrid)
: base(dataGrid)
{
datagrid = dataGrid;
}
public override void SelectRows(int startRowIndex, int endRowIndex)
{
if (startRowIndex < 0 || endRowIndex < 0)
return;
if (startRowIndex > endRowIndex)
{
var temp = startRowIndex;
startRowIndex = endRowIndex;
endRowIndex = temp;
}
if (this.DataGrid.SelectionMode == GridSelectionMode.None ||
this.DataGrid.SelectionMode == GridSelectionMode.Single)
return;
var isSelectedRowsContains = this.SelectedRows.Any();
this.SuspendUpdates();
var addedItem = new List<object>();
int rowIndex = startRowIndex;
#if !WP
ResetParentGridSelection();
#endif
var rowIndexes = this.GetRowIndexes();
var selectedrowindex = this.datagrid.ResolveToRowIndex(this.datagrid.SelectedIndex);
// if (!this.DataGrid.GridModel.HasGroup)
{
int recordindex = 0;
GridRowInfo rowInfo = null;
for (int i = rowIndex; i <= endRowIndex; i++)
{
object rowData = this.DataGrid.GetRecordAtRowIndex(rowIndex);
rowIndex = this.DataGrid.ResolveToRowIndex(recordindex);
if (!rowIndexes.Contains(rowIndex))
{
this.DataGrid.SelectedItems.Add(rowData);
this.SelectedRows.Add(GetGridSelectedRow(rowIndex));
}
recordindex++;
}
}
this.ShowAllRowSelectionBorder();
if (!isSelectedRowsContains)
{
this.RefreshSelectedIndex();
}
this.ResumeUpdates();
}
private void ResetParentGridSelection()
{
if (!(this.DataGrid is DetailsViewDataGrid))
return;
var parentDataGrid = this.DataGrid.GetParentDataGrid();
var selectionController = parentDataGrid.SelectionController as GridSelectionControllerExt;
var removedItems = selectionController.SelectedRows.ToList<object>();
var rowIndex = parentDataGrid.GetGridDetailsViewRowIndex(this.DataGrid as DetailsViewDataGrid);
selectionController.ResetSelection(rowIndex, removedItems, true);
}
protected internal void ResetSelection(int rowIndex, List<object> removedItems, bool setFocuForGrid = true)
{
var addedItems = new List<object>();
var rowInfo = this.GetGridSelectedRow(rowIndex);
if (!this.SelectedRows.Contains(rowInfo))
addedItems.Add(rowInfo);
this.DataGrid.HideRowFocusBorder();
if (removedItems != null && removedItems.Count > 0)
{
this.RemoveSelection(rowIndex, removedItems, SelectionReason.GridOperations);
}
if (addedItems.Count > 0)
this.AddSelection(addedItems, SelectionReason.GridOperations);
}
private void RefreshSelectedIndex()
{
this.DataGrid.SelectedIndex = this.SelectedRows.Count > 0 ? this.DataGrid.ResolveToRecordIndex(this.SelectedRows[0].RowIndex) : -1;
this.DataGrid.SelectedItem = this.DataGrid.SelectedItems.Count > 0 ? this.DataGrid.SelectedItems[0] : null;
}
internal List<int> GetRowIndexes()
{
return this.datagrid.SelectionController.SelectedRows.Select(rowinfo => rowinfo.RowIndex).ToList();
}
} |
protected override void ProcessPointerReleased(MouseButtonEventArgs args, Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex rowColumnIndex)
{
if (SelectionHelper.CheckShiftKeyPressed())
{
this.SelectRows(this.PressedRowColumnIndex.RowIndex, rowColumnIndex.RowIndex);
}
else
base.ProcessPointerReleased(args, rowColumnIndex);
} |
Hi Thiago ,
We are glad to know that the
reported problem has been resolved at your end. Please let us know if you have
any further queries on this. We are happy to help you.
Regards,
Farjana Parveen A
Hello,
I'm having some problems with the select all function, the performance is very low when I need to select more than 20 thousand records, I get to cases where I need to select millions and how the function uses the screen thread, this generates a performance problem and feedback.
I would like to help to create an override for the selectall function that allows me to work with a large amount of records, would it be possible?
this.SfDataGrid.SelectionController = new SelectionControllerExt(this.SfDataGrid);
public class SelectionControllerExt : GridSelectionController
{
public SelectionControllerExt(SfDataGrid sfDataGrid)
:base(sfDataGrid)
{
}
public override void SelectAll(bool canFocus = true)
{
//To do..
base.SelectAll(canFocus);
}
} |