We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Index was out of range when editing grid with GroupDropArea

Thread ID:

Created:

Updated:

Platform:

Replies:

133016 Oct 4,2017 03:43 AM Oct 9,2017 06:45 AM WPF 3
loading
Tags: SfDataGrid
BAO YADONG
Asked On October 4, 2017 03:43 AM

Hi,

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

Gnanasownthari Thirugnanam [Syncfusion]
Replied On October 5, 2017 02:03 PM

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. 


BAO YADONG
Replied On October 6, 2017 12:16 AM

Hi,

Your solution works fine. But how can i do the same in CurrentCellEndEdit event?


Gnanasownthari Thirugnanam [Syncfusion]
Replied On October 9, 2017 06:45 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;