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.

How to add new row in GridGroupingControl?

Thread ID:

Created:

Updated:

Platform:

Replies:

60759 May 10,2007 07:14 PM Aug 1,2016 08:21 AM Windows Forms 7
loading
Tags: Grouping
Person
Asked On May 10, 2007 07:14 PM

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


haneefm [Syncfusion]
Replied On May 10, 2007 07:58 PM

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

Person
Replied On May 10, 2007 09:37 PM

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

haneefm [Syncfusion]
Replied On May 11, 2007 07:38 PM

Hi Person,

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

Best regards,
Haneef

Person
Replied On May 15, 2007 03:46 AM


>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?

Jeba S [Syncfusion]
Replied On May 30, 2007 07:18 AM

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.


Mehrdad Bozorgmehr
Replied On July 29, 2016 03:58 PM

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?

Anish George [Syncfusion]
Replied On August 1, 2016 08:21 AM

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 


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.

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.

;