How to set the GridAddNewRecord as the current record in GGC

Hi,
Can you help? I have a method that will be used to add new records to GGC, but I need that record to be the current record so that text boxes linked to it will show what is being added on a per cell basis.

Is there a way to do this?

Thanks!

5 Replies

AD Administrator Syncfusion Team March 2, 2007 10:48 PM UTC

Hi,

You can use the UnsortedRecords property to find the newly record and set that record as current record using the SetCurrent method. Below is a code snippet

int Oldcount = this.gridGroupingControl1.Table.UnsortedRecords.Count;

DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
DataRow dr = dt.NewRow();
dr["Col1"] = "NewValue";
dt.Rows.Add(dr);
dt.AcceptChanges();

this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetCurrent("ColumnName");
this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetSelected(true);

Best regards,
Haneef


AD Administrator Syncfusion Team March 2, 2007 11:12 PM UTC

Thanks; Actually, what I mean is the row for new records (with the *), the GridAddNewRecord, which I guess has cells of type GridTableCellType.AddNewRecordFieldCell -
I want to be able to 'see' the events (data entry) in that row and display them in text boxes, so I need it to be the current record...

Thanks again!

>Hi,

You can use the UnsortedRecords property to find the newly record and set that record as current record using the SetCurrent method. Below is a code snippet

int Oldcount = this.gridGroupingControl1.Table.UnsortedRecords.Count;

DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
DataRow dr = dt.NewRow();
dr["Col1"] = "NewValue";
dt.Rows.Add(dr);
dt.AcceptChanges();

this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetCurrent("ColumnName");
this.gridGroupingControl1.Table.UnsortedRecords[Oldcount].SetSelected(true);

Best regards,
Haneef


AD Administrator Syncfusion Team March 5, 2007 11:36 PM UTC

Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

Best regards,
Haneef


AD Administrator Syncfusion Team March 6, 2007 01:08 AM UTC

Thanks Haneef - will try it.

>Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

Best regards,
Haneef


AD Administrator Syncfusion Team March 6, 2007 04:14 PM UTC

Hi Haneef,
I tried this and the event is triggered, but the record I add doesn't stay. After I hit 'enter', the AddNew method is called, but no new record shows up. What could be the cause?

Thanks again,




>Thanks Haneef - will try it.

>Hi,

One way you can do this by handling the CurrentRecordContextChange event of the grid and call the Table.AddNew method followed by AddNewRecord.BeginEdit() method. Here is a code snippet.

private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if( e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete
&& e.Record.Kind == DisplayElementKind.AddNewRecord)
{
e.Table.BeginEdit();
e.Table.AddNew();
e.Table.AddNewRecord.BeginEdit();
}
}

Best regards,
Haneef

Loader.
Up arrow icon