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

Adding new row

Hi,

Will you please tell me how to add a new row in GridGroupingControl programatically without creating a new row in underlying datasource.

Cheers,
Vinod

2 Replies

AD Administrator Syncfusion Team February 12, 2007 03:26 PM UTC

Hi Vinod,

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


AD Administrator Syncfusion Team February 12, 2007 05:57 PM UTC

Hi Haneef,

Sorry but this is not as per my requirement. Because it adds a new record in underlying datasource and then SetValue() method tries to save values in fields of newly created row in underlying datasource.

My requirement in detail:
-----------------------------
I am using GridGrouping control for displaying Hierarchical data. But I don't want to display standard plus/minus buttons for expanding and collapsing child record.
The datasource is EntityCollection which contains the collection of Department entities. Each Department entity contains collection of SubDepartment entities.

Department Entity:
-----------------
DeptNo int,
DepartmentDescription string

SubDepartment Entity:
-----------------
SubDeptNo int,
SubDepartmentDescription string

I want to show the columns (in unbopund mode) for all the fields from both (Department and SubDepartment) entities at parent (Department) level.
If a department has only one Subdepartment then there will be only one record in grid.
If a department has two Subdepartments then there will be three records in grid.
First record will list only Department details and cells for subdepartment will be blank
Second and Third records will list SubDepartment details and cells for Department will be blank.

For achieving this I was thinking, I will add new records in grid if child collection contains more than one entity and this action will not create new entities in underlying EntityCollection. These new records should map to Child Collection.

Will you please explain how it can be achieved?

Cheers,
Vinod

Loader.
Live Chat Icon For mobile
Up arrow icon