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

How to add new row in GridGroupingControl?

Hi,

I have two datasets, they are merged together and show in GridGroupingControl with Relation set.

Now I want to add a new row in the GridGroupingControl. How can I do this?
I have tried the below but it does work..

this.gridGroupingControl1.GetTableControl("XXX").Model.Rows.InsertRange(3, 1);


Thanks,
Person


7 Replies

HA haneefm Syncfusion Team May 10, 2007 11:58 PM UTC

Hi,

For AddNewRow:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

If you want to show the AddNewRow(Blank Row) in the top section of the group, you can set the ShowAddNewRecordBeforeDetails property to true. Here is a code snippet

//For Main Groups
this.grid.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = true;
this.grid.TopLevelGroupOptions.ShowAddNewRecordAfterDetails = false;

//For Main Groups
this.grid.NestedTableGroupOptions.ShowAddNewRecordBeforeDetails = true;
this.grid.NestedTableGroupOptions.ShowAddNewRecordAfterDetails = false;

//For Child Groups
this.grid.ChildGroupOptions.ShowAddNewRecordBeforeDetails = true;
this.grid.ChildGroupOptions.ShowAddNewRecordAfterDetails = false;

For add a new record.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

You can use the AddNewRecord property of the GridTable to add new record in a grid. Please try the below code snippet and let me know if this helps.

this.gridGroupingControl1.Table.AddNewRecord.SetCurrent();
this.gridGroupingControl1.Table.AddNewRecord.BeginEdit();
this.gridGroupingControl1.Table.CurrentRecord.SetValue("ColumnName","Value");
this.gridGroupingControl1.Table.AddNewRecord.EndEdit();

Best regards,
Haneef


PE Person May 11, 2007 01:37 AM UTC

Hi Haneef,

I would like to provide more details for what I want.

First, I want to add a new row but not new record. Second, I have a context menu, the menu item, "Add", will be shown when right click on a row. What I want is if the the item "Add" is clicked, a new row will be inserted under the row which right clicked, and the content of the original row is copied to the new row also.

Hence, it is possible case that the new added row will be in between of existing rows.

How can I do this? Seems the row index need to be specified.

Thanks.

Regards,
Person


HA haneefm Syncfusion Team May 11, 2007 11:38 PM UTC

Hi Person,

Please try the attached sample and let me know if this helps.
GGCInsertRow.zip

Best regards,
Haneef


PE Person May 15, 2007 07:46 AM UTC


>Hi Person,

Please try the attached sample and let me know if this helps.
GGCInsertRow.zip

Best regards,
Haneef


Many Thanks Haneef, it works fine!

BTW, I want to know if it must need to involve datatable which the GridGroupingControl's datasource refer to, just like the example you provided. As I just want to add new row on the grid and on screen, but find "gridGroupingControl1.TableControl.Table.Records.Rows" doesn't work as expected, or other way to do the just on-screen changes?


JS Jeba S Syncfusion Team May 30, 2007 11:18 AM UTC

Hi Person,

You cannot insert a row into a GridGroupingControl. You must insert it into your DataTable. A GridGroupingControl normally holds no data. The data comes from the datasource and is just displayed in the grid. You cannot add a row in the middle of the grid, because the data in the middle of the grid comes from the datatable.

If you need this functionality, you might consider using a GridControl as this control does store data inside the grid, and can easily insert rows using the method you mentioned.

Best Regards,
Jeba.



MB Mehrdad Bozorgmehr replied to Jeba S July 29, 2016 07:58 PM UTC

Hi Person,

You cannot insert a row into a GridGroupingControl. You must insert it into your DataTable. A GridGroupingControl normally holds no data. The data comes from the datasource and is just displayed in the grid. You cannot add a row in the middle of the grid, because the data in the middle of the grid comes from the datatable.

If you need this functionality, you might consider using a GridControl as this control does store data inside the grid, and can easily insert rows using the method you mentioned.

Best Regards,
Jeba.


Hi Sir

I added a GridGroupControl to my Form. Then I added some Columns to TableDescriptor of this grid. Then I want to add a new record to this grid in end of grid rows.This grid doesn't have any record (row) yet, and I suppose to add first record (row) to this grid. Your code Below didn't work to me.


In TableDescriptor Allow New is True. ChildernGroupeOption in TableDescriptor AddNewRecordBeforeDetails is True. In TableDescriptor We have 10 Columns and We don't ColumnSet, TopLevelGroupOption AddNewRecordBeforeDetails is True. 

In main Grid (Not TableDescriptor) TableOption is Ok, and TopLevelGroupOption AddNewRecordBeforeDetails is True.

How Can I add a row to this table?


AG Anish George Syncfusion Team August 1, 2016 12:21 PM UTC

Hi Mehrdad, 
 
Thank you for using Syncfusion products. 
 
We tried to replicate the issue in a simple sample but we were unable to reproduce it. Please check the below sample in which we have tested. Please reproduce the issue in the below sample so that we can give you a quick solution regarding this. 
 
Sample: 
 
Regards, 
Anish 


Loader.
Live Chat Icon For mobile
Up arrow icon