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.
Syncfusion Feedback

GDBG - Validation/Data Binding issues

Thread ID:

Created:

Updated:

Platform:

Replies:

47884 Aug 15,2006 10:10 PM UTC Feb 22,2007 11:17 PM UTC Windows Forms 6
loading
Tags: GridControl
Jonathan Quail
Asked On August 15, 2006 10:10 PM UTC

We are experiencing some strange behaivor with the GDBG in version 4.2.0.37. We are having 3 issues:

1.It would appear that if you change the value of a grid cell and hit the Up/Down arrow keys, the CurrentCellValidating/CurrentCellValidated events do not fire.

If you click Left/Right or Tab/Shift + Tab the events fire. But Up/Down out of the cell they do not fire. Is this by design? Is there any way to force the validation to occur in those cases?

2.We are having a similar issue with hitting the "Enter" key. In our application, we do our own Validation in the OnCurrentCellValidated method (Reason being - we don''t want to force focus back on the cell if it failed, we''ll just reset the value ourselves).

We do:
---
BeginUpdate ()
Binder.SuspendBinding ();

if (validationFailed)
{ valueToSet = [original value]; }
else
{ valueToSet = [new value]; }

dataRowView[fieldName] = valueToSet;
CurrentCell.Renderer.ControlValue = valueToSet;

Binder.ResumeBinding ();
EndUpdate ();
---

Where:
- dataRowView is the current data row from the data view the grid is bound to.

As soon as the ResumeBinding () is hit, the cell reverts back to the value before you entered anything. So the control value does not reflect what "valueToSet" was in the case where validation succeeded.

If the original value is "Hello" and you change that to "Goodbye" and hit Enter (which should move to the next cell), and the validation succeeds, the resulting value in the cell is "Hello". When it should be "Goodbye".

Hopefully that makes sense.

3. The last issue we are having is using the same block of code from above - but if it is acting on the "GridCheckBoxCellRenderer" type, doing:
"CurrentCell.Renderer.ControlValue = valueToSet;" does not always work (works if you click out of the grid, or use the arrow keys - but not tab out or click on another cell in grid).

But if you do:
"this[CurrentCell.RowIndex, CurrentCell.ColIndex].CellValue = valueToSet;" it will work in all cases.

Issue #3 can be worked around, although I am baffled as to why doing it that way works, so we simply have:

if (CurrentCell.Renderer is GridCheckBoxCellRenderer)
{
this[CurrentCell.RowIndex, CurrentCell.ColIndex].CellValue = valueToSet;
}
else
{
CurrentCell.Renderer.ControlValue = valueToSet;
}


Any ideas on these issues would be a huge help.

Thanks!

Jonathan Quail

Administrator [Syncfusion]
Replied On August 16, 2006 06:58 AM UTC

Hi Jonathan,

Issue 1& 2:

By default, The CurrentCellValidating / CurrentCellValidated event is fired only once when the user tries to leave the current cell after editing(changes made in a CurrentCell[ CurrentCell.IsModified = True]).To force the validation on CurrentCell, you can call the CurrentCell.Validate() method. Validate method checks CurrentCell.IsModified flag.If it is TRUE, it fires the Validating events.

Issue 3:

Glad you have a solution to this issue.The reason is that the ConfirmChanges() is called in between the GridCheckBoxCellRenderer MouseUp and OnClickedCheckBox events in a CheckBox cell. To change the value of the checkbox cell in Validating Event,You need to use CellValue property of the GridStyleInfo class.

this[CurrentCell.RowIndex, CurrentCell.ColIndex].CellValue = valueToSet;

Please refer the below KB Article for validate event in grid.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=340

Let me know if this helps.
Best Regards,
Haneef


Jonathan Quail
Replied On August 16, 2006 07:30 PM UTC

Issue 3 - Thanks for the explanation, that makes sense then why my workaround does the trick.

Issue 1 + 2.

My observation is that in case 1, where you exit the field using the Up or Down arrow, the CurrentCellValidating event is *not* fired at all. I can understanding the idea of only having it fire once when you try to leave a field. But in this case, it is never firing when they exit the field in this way.

Using the Left/Right arrow does fire the event. But up/down does not.

Issue 2 (exit using "Enter" key) - the event *does* fire, except the value that we entered is lost, and the value is reverted back to whatever it was before we changed it. And using the same block of code that I originally posted above - we set the value the same way as we do when we exit any other way, just with "Enter" it acts differently.

Administrator [Syncfusion]
Replied On August 17, 2006 09:26 AM UTC

Hi Jonathan,

We tried to reproduce this issue in 4.2.0.37, but could not get this issue. Maybe I am not following the steps that you are doing. Attached sample working fine here. Can you post a small sample showing this problem or tell us how to see it in the Attached sample?

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBGValid_b699f717.zip

Thanks for your patience.
Regards,
Haneef

Jonathan Quail
Replied On August 21, 2006 03:36 PM UTC

Thanks for the example. We have not been able to reproduce our issue with it.

But now I believe that the issue is something on our end that is causing it.

Thank you for your help.

Jonathan

Rob Oesch
Replied On February 22, 2007 10:07 PM UTC

Jonathan,

We are experiencing the same problem with a GridDataBoundGrid. The DataSource is a custom collection. How did you resolve the issues described in problem 1?

Thank You in advance!
Rob

Administrator [Syncfusion]
Replied On February 22, 2007 11:17 PM UTC

Hi Rob,

Try setting the CurrentCell.IsModified property to true in CurrentCellKeyDown event of the Grid.

if( this.grid.CurrentCell.IsEditing )
this.grid.CurrentCell.IsModified = true;

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

;