Index was out of range when editing grid with GroupDropArea
Hi,
Attachment: ss_8aece136.rar
May i know why the exception of Index was out of range occur when trying to edit cell in grouping mode?
xaml.cs:
private void dgDrug_CurrentCellValueChanged(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellValueChangedEventArgs args)
{
Model.VEntityList[args.RowColumnIndex.RowIndex -1].IsEdited = True;
}
xaml:
<Style TargetType="Syncfusion:VirtualizingCellsControl" x:Key="RowStyle">
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsEdited}" Value="True">
<Setter Property="Foreground" Value="#ff0000" />
</DataTrigger>
</Style.Triggers>
</Style>
Above line is working fine if i don't drop a column to group area. There are few scenarios that the exception will occur when i group a column:
1) After editing the cell, mouse click focus on other cell
2) Remove the grouping from group drop area.
Another issue is when i group a particular column, my IsEdited and RowIndex is totally mess up. please see screenshot for sample
Attachment: ss_8aece136.rar
SIGN IN To post a reply.
3 Replies
GT
Gnanasownthari Thirugnanam
Syncfusion Team
October 5, 2017 06:03 PM UTC
Hi YADONG
As per your given code snippet we found that, you have set the IsEdited as true based on RowIndex in CurrentCellValueChanged so grouping cases it is not working. Now we have modified by setting IsEdited as true based on record as like below code example.
| private void datagrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs e) { //You can set the IsEdited as True for edited record here. (e.Record as OrderInfo).IsEdited = true; } |
Please modify the above code in your application.
We have prepared the sample based on requirement and given code snippet, you can download the sample from below mentioned location.
Sample location:
Please let us know if this helps you.
Regards,
Gnanasownthari T.
BY
BAO YADONG
October 6, 2017 04:16 AM UTC
Hi,
Your solution works fine. But how can i do the same in CurrentCellEndEdit event?
GT
Gnanasownthari Thirugnanam
Syncfusion Team
October 9, 2017 10:45 AM UTC
Hi YADONG,
You can set the IsEdited flag as true in CurrentCellEndEdit event as like below code example.
| private void datagrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e) { var recordIndex = this.datagrid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex); if (recordIndex >= 0) { if (this.datagrid.View.TopLevelGroup != null) { //Get the record from TopLevelGroup.DisplayElements. var data = (this.datagrid.View.TopLevelGroup.DisplayElements[recordIndex] as RecordEntry).Data; //You can set the IsEdited flag as true here for Grouping cases. (data as OrderInfo).IsEdited = true; } else { var data = (this.datagrid.View.Records[recordIndex] as RecordEntry).Data; (data as OrderInfo).IsEdited = true; } } } |
As per your requirement we have modified the sample, you can download the same from below mentioned location.
Sample location:
Please let us know if this helps you.
Regards,
Gnanasownthari T.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BY BAO YADONG
- Oct 4, 2017 07:43 AM UTC
- Oct 9, 2017 10:45 AM UTC