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
close icon

SaveRecord and GGC

Hi,

I have a GGC which is bound to a business object. The business object contains several properties which are columns in my grid.

Now I have set the CellValueType for each column to "System.String" and during the save operation I want to convert the string to the corresponding data type of the underlying data (my business object property). So I thought there is a SaveRecord event or something else, but I didn't find a suitable one. Can you give me a hint how I can solve my concern?

6 Replies

AD Administrator Syncfusion Team March 2, 2007 08:22 PM UTC

Hi,

You can handle the RecordValueChanging event of the Grid and set the e.NewValue to custom object. Please try the attached sample and let me know if this helps.

private void gridGroupingControl1_RecordValueChanging(object sender, RecordValueChangingEventArgs e)
{
if( e.Column == "CustomObject" )
{
e.NewValue = new Name("NewFirstName","NewLastName");
}
}

Sample : http://websamples.syncfusion.com/samples/Grid.Windows/GGCCustomObject/main.htm

Best regards,
Haneef


AD Administrator Syncfusion Team March 5, 2007 02:03 PM UTC

Hi Haneef,

thank you for your fast answer. Is there no way to set the new value in the validating event?

So I am validating with a custom class and later on in the RecordValueChanging event I have to check the same thing again and set the value there. So I am locking for a way to set the value in the validating event.

Any help would be great.

Cheers,
Tom

>Hi,

You can handle the RecordValueChanging event of the Grid and set the e.NewValue to custom object. Please try the attached sample and let me know if this helps.

private void gridGroupingControl1_RecordValueChanging(object sender, RecordValueChangingEventArgs e)
{
if( e.Column == "CustomObject" )
{
e.NewValue = new Name("NewFirstName","NewLastName");
}
}

Sample : http://websamples.syncfusion.com/samples/Grid.Windows/GGCCustomObject/main.htm

Best regards,
Haneef


AD Administrator Syncfusion Team March 6, 2007 01:11 AM UTC

Hi Tom,

Please try this code snippet to set a cell value in TableControlCurrentCellValidating event.

private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if(style.TableCellIdentity.Column != null &&
style.TableCellIdentity.Column.Name == "CustomObject")
cc.Renderer.ControlValue = new Name("VNewFirstName","VNewLastName");
}

Best regards,
Haneef


AD Administrator Syncfusion Team March 6, 2007 07:30 AM UTC

Hi Haneef,

thank you for your answer, but this doesn't seem to work. I have add the corresponding event and the control value of the renderer is set to a new value, but the grid still displays the old value.

I have attached the modified sample.

Thanks in advance

GGCCustomObjectModified.zip


AD Administrator Syncfusion Team March 7, 2007 11:09 AM UTC

Hi,

just wanna bring this thread up - I hope somebody can take a look at this issue again.


AD Administrator Syncfusion Team March 7, 2007 08:58 PM UTC

Hi Tom,

My apologizes for the delay caused on this issue.

You can try this code in a TableControlCurrentCellValidating event of the grid.

void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
if (style.TableCellIdentity.Column != null &&
style.TableCellIdentity.Column.Name == "CustomObject")
{
Name newName = new Name("VNewFirstName", "VNewLastName");
if (cc.Renderer.ControlValue != newName)
{
cc.IsModified = false;
e.TableControl.Table.CurrentRecord.SetValue("CustomObject", newName);
}
}
}

Thanks for your patience.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon