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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GroupCaptionCell CellType -> Editable TextBox ; Two-waydatabinding

Thread ID:

Created:

Updated:

Platform:

Replies:

48653 Aug 31,2006 09:16 PM UTC Sep 4,2006 07:02 AM UTC WinForms 3
loading
Tags: Grouping
jamesb
Asked On August 31, 2006 09:16 PM UTC

Is it possible to make the Grid Caption row like a regular cell, that is editable instead of static and making the the new summary value trigger a manual update of the underlying datasource (that logic will be provided by me). Sort of like two way databinding

Administrator [Syncfusion]
Replied On September 1, 2006 10:18 AM UTC

Hi James,

Issue 1: Is it possible to make the Grid Caption row like a regular cell, that is editable instead of static?

Yes. You can handle the QueryCellStyleInfo event to set the Style property of the GroupCaptionCell. See the below code snippet for more details.

if(e.TableCellIdentity.TableCellType==GridTableCellType.GroupCaptionCell || e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
{
e.Style.CellType = "TextBox";
e.Style.BackColor = Color.White

//By default Enable property of GroupCaptionCell to False.
//you need to change the Enabled property to True.
e.Style.Enabled = true;

//By default ReadOnly property of GroupCaptionCell to True.
//you need to change the ReadOnly property to False.
e.Style.ReadOnly = false;

}

Issue 2: Update the record using GroupCaptionCell;

You can handle the TableControlCurrentCellEditingComplete event to update the related records in a group. See the below code snippet for more details.

GridCurrentCell cc = e.TableControl.CurrentCell;

//Get the TableCellStyleInfo from GridStyleInfo object
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if( style != null)
{
//Check the currentcell is in GroupCaptionCell or not....
if ( style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell || style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
{
// get the CaptionRow from the DisplayElement.
GridCaptionRow gr = style.TableCellIdentity.DisplayElement as GridCaptionRow ;

//Accessing the related records in a Group...
foreach(Record rec in gr.ParentGroup.Records)
{
//Update the values in a record...
rec.SetValue( gr.ParentGroup.Name,"UpdatedValue");
//Calling endedit to save the changes
rec.EndEdit();
}
}
}

Let me know if this helps.
Best Regards,
Haneef

jamesb
Replied On September 1, 2006 01:15 PM UTC

Hi Hannef:

Option 1 works OK for me. I am able to set the Caption like a regular grid cell.

I''m having a problem with option 2.
When I entered and value in the cell and leave the cell, the value is blanked out by the grid.
When I step thru the code, I noticed that gr.ParentRecord is null.

Basically, what I am trying to accomplish is
something like this :

Caption Title : 3 5
item1 1 4
item2 2 1

Caption Title is the caption row that I wanted to make editable in option 1. item1 and item2 are the child records. When I update the first cell in the caption row to 4, for example, under the covers, I will add a new row to the underlying datasource so that the Caption Row will always equal the SUM or the COUNT of the child records. This is sort of like a two-way databinding between the Caption Row and its child records.

The issuse that I need to get over first is that the caption row is not accepting any input that I typed into its cell.

Hopes this makes sense.

James


>Hi James,

Issue 1: Is it possible to make the Grid Caption row like a regular cell, that is editable instead of static?

Yes. You can handle the QueryCellStyleInfo event to set the Style property of the GroupCaptionCell. See the below code snippet for more details.

if(e.TableCellIdentity.TableCellType==GridTableCellType.GroupCaptionCell || e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
{
e.Style.CellType = "TextBox";
e.Style.BackColor = Color.White

//By default Enable property of GroupCaptionCell to False.
//you need to change the Enabled property to True.
e.Style.Enabled = true;

//By default ReadOnly property of GroupCaptionCell to True.
//you need to change the ReadOnly property to False.
e.Style.ReadOnly = false;

}

Issue 2: Update the record using GroupCaptionCell;

You can handle the TableControlCurrentCellEditingComplete event to update the related records in a group. See the below code snippet for more details.

GridCurrentCell cc = e.TableControl.CurrentCell;

//Get the TableCellStyleInfo from GridStyleInfo object
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if( style != null)
{
//Check the currentcell is in GroupCaptionCell or not....
if ( style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell || style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionSummaryCell)
{
// get the CaptionRow from the DisplayElement.
GridCaptionRow gr = style.TableCellIdentity.DisplayElement as GridCaptionRow ;

//Accessing the related records in a Group...
foreach(Record rec in gr.ParentGroup.Records)
{
//Update the values in a record...
rec.SetValue( gr.ParentGroup.Name,"UpdatedValue");
//Calling endedit to save the changes
rec.EndEdit();
}
}
}

Let me know if this helps.
Best Regards,
Haneef

Administrator [Syncfusion]
Replied On September 4, 2006 07:02 AM UTC

Hi James,

You can use the SourceList property add to a new record in a group using the TableControlCurrentCellEditingComplete event. See the below code snippet for more details.

GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if( style != null)
{
if ( style.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
e.TableControl.Table.BeginEdit();

//To get the Datasource of the Table.
DataView dv = e.TableControl.Table.SourceList as DataView;
DataRow dr = dv.Table.NewRow();

GridCaptionRow gr = style.TableCellIdentity.DisplayElement as GridCaptionRow ;
Group group = gr.ParentGroup;

//To set the updated value of the Table.
dr["ColumnName"] = "updateValue";
dr[group.Name] = group.Category; // for setting the group name.

//Add the New record in a group...
dv.Table.Rows.Add(dr);
e.TableControl.Table.EndEdit();
}
}

Let me know if this helps.
Best Regards,
Haneef

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.

Warning Icon 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.Close Icon

;