Hi!
I'm using a ggc and want to Save the cellvalue with every single change (key-event or copy-paste). I started with this:
private void ggc1_TableControlCurrentCellStartEditing(
object sender,GridTableControlCancelEventArgs e) {
e.TableControl.CurrentCell.Model.ActiveTextChanged+=Model_ActiveTextChanged;
}
void Model_ActiveTextChanged(object sender,GridCellEventArgs e) {
GridTextBoxCellModel gtbcm = sender as GridTextBoxCellModel;
// How to save the Cellvalue into the underlying BusinessObject?
}
private void gridGroupingControl1_TableControlCurrentCellEditingComplete(object sender,GridTableControlEventArgs e) {
e.TableControl.CurrentCell.Model.ActiveTextChanged-=Model_ActiveTextChanged;
}
Can anyone help?
Greeting Falk
RC
Rajadurai C
Syncfusion Team
March 26, 2009 03:15 PM UTC
Hi Falk,
Thanks for your interest in Syncfusion products.
The underlying datasource of the grid get updated only when EndEdit is called. This is called by default, when a cell loses focus. If you try to make this call explicitly in your case, the cell will lose focus on typing a single character and cannot allow you to type further continuously which is not a desired behavior.
this.grid.Table.CurrentRecord.EndEdit();
this.grid.Table.EndEdit();
Hence, the underlying data cannot be updated while EndEdit is not called.
Regards,
Rajadurai
AD
Administrator
Syncfusion Team
March 27, 2009 03:58 PM UTC
It can:
void Text_ActiveTextChanged(object sender,GridCellEventArgs e) {
if(gridGroupingControl1.Table.CurrentElement!=null) {
GridTextBoxCellRenderer textRenderer = gridGroupingControl1.TableControl.CurrentCell.Renderer as GridTextBoxCellRenderer;
string text=null;
MyClass ep = gridGroupingControl1.Table.CurrentElement.GetData() as MyClass;
MyClass.MyProperty = textRenderer.ControlText;
}
}
RC
Rajadurai C
Syncfusion Team
March 31, 2009 01:25 PM UTC
Hi Falk,
Thanks for your update. With the provided code, it is possible to get the text in a seperate object on each edit in a cell. But it is not possible to commit the change to the underlying datarow position while editing in that cell. If tried, it will throw NullReferenceException.
If you feel the workaround which you provided satisfies the requirement in your application, please make use of it.
Please let me know if you have any further concerns.
Regards,
Rajadurai