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.

Add New Record Row..

Thread ID:

Created:

Updated:

Platform:

Replies:

22307 Dec 9,2004 06:42 AM Apr 27,2005 08:46 PM Windows Forms 18
loading
Tags: Grouping
Angela Chua
Asked On December 9, 2004 06:42 AM

Hi.. i need some help seriously.. (1)Can anyone tell me what''s the event to trigger when user is actually entering data on a new row? (2) How do you prevent user from hitting on the enter key(which adds the row to the grid Datatable) if says they enter the wrong data and i do not allow them to enter that whole row? Thankz you..

Administrator [Syncfusion]
Replied On December 9, 2004 06:56 AM

Hi Angela, look for the CurrentRecordContextChange event. The e.Action will give information about the reason why the event was raised. It can be one of /// /// Specifies how the current record context changes. /// /// /// This enum is used by the property /// of the class. public enum CurrentRecordAction { /// /// was called. You can cancel this operation by /// setting the Cancel property. /// BeginEditCalled, /// /// is complete and returns. /// BeginEditComplete, /// /// was called. You can cancel this operation by /// setting the Cancel property. /// EndEditCalled, /// /// is complete and returns. /// EndEditComplete, /// /// was called. You can cancel this operation by /// setting the Cancel property. /// CancelEditCalled, /// /// is complete and returns. /// CancelEditComplete, /// /// was called. You can cancel this operation by /// setting the Cancel property. /// NavigateCalled, /// /// is complete and returns. /// NavigateComplete, /// /// was called. You can cancel this operation by /// setting the Cancel property. /// LeaveRecordCalled, /// /// is complete and returns. /// LeaveRecordComplete, /// /// was called. You can cancel this operation by /// setting the Cancel property. /// EnterRecordCalled, /// /// is complete and returns. /// EnterRecordComplete, CurrentFieldChanged } When the user starts modifying a cell in the current record, e.Action will be BeginEditCalled When the user has pressed Enter then e.Action will be EndEditCalled. You can cancel this operation by setting e.Cancel. You can check if the record is the AddNewRecord with "e.Record is AddNewRecord". Stefan

Administrator [Syncfusion]
Replied On March 12, 2005 11:37 AM

this is the scenario i am facing. at new row of ggc, i want to detect if the value entered in a cell is duplicate in another row. if it is, i want to cancel the action of adding that new row. i tried detecting the event on GridGroupingControlJobFunctions_CurrentRecordContextChange, setting e.cancel = true on e.action = EndEditCalled did not work. where did i go wrong?

Administrator [Syncfusion]
Replied On March 13, 2005 05:14 AM

Here is a TableControlCurrrentCellValidating event handler that will not let your user leave a cell in the AddNew row if he enters something that is already in an existing row. Will this serve your needs?
private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, 
GridTableControlCancelEventArgs e)
{
	GridCurrentCell cc = e.TableControl.CurrentCell;
	GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
	if(style.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell)
	{
		string colName = style.TableCellIdentity.Column.MappingName;
		object newValue = cc.Renderer.ControlValue;
		foreach(Record r in e.TableControl.Table.Records)
		{
			if(r.GetValue(colName).Equals(newValue))
			{
				//duplicate found
				e.Inner.Cancel = true;
			}
		}
	}
}

Administrator [Syncfusion]
Replied On March 30, 2005 02:13 PM

the sample codes work if the check is performed on a single column. what if i want to perform it on 2 columns. ensuring column 1 do not have duplicate, and column 2 cannot be empty?

Administrator [Syncfusion]
Replied On March 30, 2005 07:28 PM

If you need to check multipe columns you should handle the CurrentRecordContextChange event. Example: private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e) { Record r = e.Record as Record; if (r != null && e.Action == CurrentRecordAction.EndEditCalled) { try { object id = r.GetValue("CategoryID"); if (id is DBNull || (int) id > 4) { object desc = r.GetValue("Description"); if (desc is DBNull || desc.ToString() == "") { e.Cancel = true; MessageBox.Show("Error: Category > 10 or Categort null and Description empty"); } } } catch (Exception ex) { e.Cancel = true; MessageBox.Show(ex.Message); } } } You can download a sample project here: CS.zip Stefan >the sample codes work if the check is performed on a single column. what if i want to perform it on 2 columns. ensuring column 1 do not have duplicate, and column 2 cannot be empty?

Administrator [Syncfusion]
Replied On March 31, 2005 10:23 AM

i tried running the demo scripts. but it still allow me to go to the next record. this is what i did: 1. i cleared the description field for id = 6. 2. hit enter 3. click [ok] for the prompt 4. hit down arrow key.

Administrator [Syncfusion]
Replied On March 31, 2005 11:41 AM

To catch the use of the navigation keys, check for NavigateCalled as well as EndEditCalled in the event handler.
if (r != null && 
	(e.Action == CurrentRecordAction.EndEditCalled
	|| e.Action == CurrentRecordAction.NavigateCalled))
{

Administrator [Syncfusion]
Replied On March 31, 2005 03:42 PM

I see what you mean. That should not happen when you set e.Cancel = true. It is limited to navigation with arrow keys. We will get that fixed in our codebase. Stefan >To catch the use of the navigation keys, check for NavigateCalled as well as EndEditCalled in the event handler. > > >
>if (r != null && 
>	(e.Action == CurrentRecordAction.EndEditCalled
>	|| e.Action == CurrentRecordAction.NavigateCalled))
>{
>

Administrator [Syncfusion]
Replied On April 2, 2005 10:14 AM

i tried using clay''s proposed solution. it''s still not working... how do i obtain the fix to the codebase for this?

Administrator [Syncfusion]
Replied On April 2, 2005 11:02 AM

Here is the sample above. Using 3.0.1.0 and following the steps you listed, I cannot leave the row either with the keyboard or the mouse. Can you? http://www.syncfusion.com/Support/user/uploads/forum_Grouping_Validate_31a06ee.zip There is a public release being finalized now, but I do not know when it will be uploaded, and am not sure that a fix for this problem made it into this release or not.

Administrator [Syncfusion]
Replied On April 2, 2005 09:53 PM

i tried and i am still able to reproduce the bug. this is what i did. 1. click on description cell of id = 6 2. clear the content 3. hit down arrow key 4. click ok for the prompt. i really hope it can make it into this release as i don''t want to resort to using a popup form to perform my validations. for now as it seems, the only way out is to use this popup form for creating/updating records.

Administrator [Syncfusion]
Replied On April 3, 2005 04:33 AM

Yes, this change has made it into the upcoming release. In that release, checking on CurrentRecordAction.EndEditCalled and cancelling there prevents you from leaving the cell either using teh keyboard or the mouse.

Administrator [Syncfusion]
Replied On April 7, 2005 10:44 AM

i downloaded 3.2.0.0. but it seem that i am still able to leave the record. my codes look like this: Private Sub GridGroupingControlEducations_CurrentRecordContextChange(ByVal sender As Object, ByVal e As Syncfusion.Grouping.CurrentRecordContextChangeEventArgs) Handles GridGroupingControlEducations.CurrentRecordContextChange Dim rec As Syncfusion.Grouping.Record = e.Record If Not rec Is Nothing AndAlso (e.Action = Syncfusion.Grouping.CurrentRecordAction.EndEditComplete) Then Try If rec.GetValue("Education") Is DBNull.Value OrElse rec.GetValue("EducationLevel") Is DBNull.Value Then e.Cancel = True End If Catch ex As Exception e.Cancel = True End Try End If End Sub

Administrator [Syncfusion]
Replied On April 7, 2005 12:18 PM

Try EndEditCalled instead of EndEditComplete.

Administrator [Syncfusion]
Replied On April 7, 2005 12:35 PM

i tried changing from EndEditComplete to EndEditCalled. it appears that hitting the arrow keys now work the way it is suppose to be. but hitting enter will still cause the row to be inserted. sorting the column will also cause the row to be added.

Administrator [Syncfusion]
Replied On April 8, 2005 05:48 PM

Hi Lance, we''ll have the Sort and Enter-Key behavior be fixed for the 3.2.1 build which we will get out next week. Thanks for the patience. Stefan >i tried changing from EndEditComplete to EndEditCalled. it appears that hitting the arrow keys now work the way it is suppose to be. but hitting enter will still cause the row to be inserted. > >sorting the column will also cause the row to be added.

Ken
Replied On April 25, 2005 03:02 PM

Hi, Where can I get the 3.2.1 build ? >Hi Lance, > >we''ll have the Sort and Enter-Key behavior be fixed for the 3.2.1 build which we will get out next week. > >Thanks for the patience. > >Stefan > >>i tried changing from EndEditComplete to EndEditCalled. it appears that hitting the arrow keys now work the way it is suppose to be. but hitting enter will still cause the row to be inserted. >> >>sorting the column will also cause the row to be added.

Administrator [Syncfusion]
Replied On April 27, 2005 08:46 PM

Essential Studio version 3.2.1.0 (final version of 3.2) is now available for download. You can download it from Direct-Trac (or use this link - http://www.syncfusion.com/squiffler/patches/v3.2.1.0/syncfusionessentialstudiosetup.exe). Stefan

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.

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.

;