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. Image for the cookie policy date

RecordAdded property in GGC

Hi,

Where is the event for RecordAdded ??

There is RecordDeleted, RecordExpanded etc. but could not see RecordAdded.


Actually my main requirement is that when a record is added the cursor is moved to the added record. I wan to set cursor back to the AddNewRecord record.

Regards,
Santosh U

5 Replies

RC Rajadurai C Syncfusion Team September 9, 2009 10:50 AM UTC

Hi Santosh,

Thanks for your interest in Syncfusion Products.

If a new record is added through AddNewRecord in grid, the focus moves to the new record. It is the general behavior followed in grid. If you would like to set the focus to the AddNewRecord itself even the record must be added to grid, it cannot be achieved easily by simply cancelling the event. One thing you can do is, if you are allowing the users to interact only with the addnewrecord, then the following simple workaround can help in achieving this.
//CurrentRecordContextChange event

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

This doesn't allow the focus to move out of addnewrecord once the focus is set even the new records keep adding.

Regards,
Rajadurai


SU Santosh U September 10, 2009 02:44 PM UTC

Hi Rajadurai,

This is working perfect, Can i also set focus to the fist column of grid since the columns which are at the end depend data on the first columns.

Thanks,
Santosh U


RC Rajadurai C Syncfusion Team September 11, 2009 10:10 AM UTC

Hi Santosh,

Thanks for your update.

If you would like to set the focus to the first column in addnewrecord each time new record is added, then set current cell focus to the first cell in addnewrecord and activate it in CurrentRecordContextChange event. Here is the modified code for your reference.

CurrentRecordContextChange event

void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if (e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditComplete)
{
if (e.Record.Kind == Syncfusion.Grouping.DisplayElementKind.AddNewRecord)
{
this.gridGroupingControl1.Table.CurrentRecord = this.gridGroupingControl1.Table.AddNewRecord;
e.Record.GetRecord().BeginEdit();
this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(e.Record.GetRowIndex(), 1);
this.gridGroupingControl1.TableControl.CurrentCell.Activate(e.Record.GetRowIndex(), 1);
this.gridGroupingControl1.TableControl.CurrentCell.BeginEdit();
}
}
}


Regards,
Rajadurai


SU Santosh U September 11, 2009 03:00 PM UTC

Hi Rajadurai,

I used this and it worked well also but there is another problem happened due to this. This is the same grid as I have posted in other thread (populating data on DropDownGridShowing).
Once the focus is set on the first row I am not able to see the dropdown once I click on the button :(

Please help.
Thanks,
Santosh


RC Rajadurai C Syncfusion Team September 14, 2009 07:05 AM UTC

Hi Santosh,

Thanks for your update.

Please refer to the following sample in which the workaround provided for addnewrecord is implemented along with the sample 'GGCAddNewRowTest'. When the new record has focus, the dropdown of the other columns of the new record can be viewed by clicking on dropdownbutton.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F89769.zip

With this workaround, the focus cannot be moved from the AddNewRecord to other records as requested before.

Let me know if you have any further concerns.

Regards,
Rajadurai

Loader.
Live Chat Icon For mobile
Up arrow icon