Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1180
Not enough context to add a new row
posted

Lets consider following sample : grid with some columns, refresh button on it, grouping available.

private void Form1_Load(object sender, EventArgs e)
{ Initialize(); }

private void ultraButtonRefresh_Click(object sender, EventArgs e)
{ dataTable1.Rows.Clear();  Initialize(); }

private void Initialize()
{
    for (int y = 0; y < 10; y++)
    {
        UltraGridRow row = m_grid.DisplayLayout.Bands[0].AddNew();
        row.Cells[0].Value = y;
    }
}

Important thigs from designer.cs:

- ultraGridBand1.RowLayoutStyle = Infragistics.Win.UltraWinGrid.RowLayoutStyle.GroupLayout;
- this.m_grid.DisplayLayout.Override.AllowGroupBy = Infragistics.Win.DefaultableBoolean.True;
- this.m_grid.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;

Case 1: When rows are by grouped by one column (in designer) rows do not appear silenty, or sometimes exception does happen, behaviour incosistent, depends if there were groups in row layout designer :

2. When we are not grouped, everything loads OK, addnew somehow figures out the active row which gives it loading context:

3. Bad things start to happen if we have app, as code above - in our app grid starts as not grouped, then user performs grouping and then clicks refresh.

Following exception is then raised:

System.InvalidOperationException was unhandled
  Message=Not enough context to add a new row. Either a row in this band or the parent band has to be active to provide for enough context.
  Source=Infragistics2.Win.UltraWinGrid.v11.1
  StackTrace:
       at Infragistics.Win.UltraWinGrid.UltraGridBand.AddNew(Boolean calledFromAddNew)
       at Infragistics.Win.UltraWinGrid.UltraGridBand.AddNew()
       at infra1.Form1.Initialize() in C:\C#\infra\infra4\infra1\Form1.cs:line 35     

 

Case is obvious - the control does not know where to put newly created row, as values for each of grouping column have to be provided.

But we are about to fill values which would allow to do that - is there a way to perform two step row adding, as in DataTable - create + fill + insert?

Maybe it would be possible to somehow suspend synchronization for time of value filling to new row?

I know there are ways of adding row to datasource etc, but #3 is exactly the bug we are getting and looking for an easy way to fix exactly such a situation.

Parents Reply Children
No Data