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.

Custom Renderer OnSaveChanges not called with GDBG in 1.6.1.8

Thread ID:

Created:

Updated:

Platform:

Replies:

29181 May 18,2005 11:51 AM May 26,2005 02:13 PM Windows Forms 10
loading
Tags: GridControl
Sebastien Astie
Asked On May 18, 2005 11:51 AM

Hi, I created a custom renderer and model based on one of the samples provided with the grid. I cannot get the OnSaveChanges method to be called when I move from cell to cell. If I move from a cell to a control on my form then OnSaveChanges is called. I attached my Renderer and Model. What did I do wrong ? Sebastien BasisPointTextBox_2537.zip

Administrator [Syncfusion]
Replied On May 18, 2005 02:17 PM

Is your editTextBox_DecimalValueChanged method being hit? If so, does this code get hit? CurrentCell.IsModified = true; In order for OnSaveChanges to be called, CurrentCell.IsModified must be true.

Sebastien Astie
Replied On May 18, 2005 06:22 PM

Hi Clay, Yes CurrentCell.IsModified = true; is hit. I do not understand why I have to click on a control outside the grid in order to have OnSaveChanges to be called... Sebastien >Is your editTextBox_DecimalValueChanged method being hit? If so, does this code get hit? > >CurrentCell.IsModified = true; > > >In order for OnSaveChanges to be called, CurrentCell.IsModified must be true.

Administrator [Syncfusion]
Replied On May 18, 2005 07:59 PM

This change made OnSaveChanges get hit for me.
private void editTextBox_DecimalValueChanged(object sender, EventArgs e)
{
	if(ControlValue == null || (double)ControlValue != editTextBox.DecimalValue)
	{
		if(CurrentCell.NotifyChanging())
		{
			CurrentCell.IsModified = true;
			CurrentCell.ConfirmChanges();
			ControlValue = editTextBox.DecimalValue;
			NotifyCurrentCellChanged();
		}
	}
}

Sebastien Astie
Replied On May 19, 2005 01:34 PM

Clay, Thanks for the reply. The example you sent get the OnSaveChanges to be called. The only problem is that it calls it even if the column styleInfo.ReadOnly is true. I modified the example you sent and did it this way : private void editTextBox_DecimalValueChanged(object sender, EventArgs e) { if(ControlValue == null || (double)ControlValue != editTextBox.DecimalValue) { if(NotifyCurrentCellChanging()) { CurrentCell.IsModified = true; ControlValue = editTextBox.DecimalValue; if(!Grid.GetViewStyleInfo(RowIndex, ColIndex).ReadOnly) CurrentCell.ConfirmChanges(); NotifyCurrentCellChanged(); } } } Is that the correct way to deal with that issue ? Should I do it differently ? Thanks Sebastien

Administrator [Syncfusion]
Replied On May 19, 2005 02:40 PM

If the cell is readonly, you may want to make you edit control readonly some how so the editTextBox_DecimalValueChanged is not called in the first place.

Sebastien Astie
Replied On May 25, 2005 09:41 PM

Clay, Sorry for the delay, and thanks a lot for your help. The CurrentCell.ConfirmChanges() is causing me some troubles on grids where EnableAddNew = true; Because of the CurrentCell.ConfirmChanges(), I get the following behaviour : I have a grid with 1 row of data. I click on the cell that uses my custom renderer in the empty row (the one meant to add data). I do nothing and click on the cell that uses my custom renderer in the first row, a row gets added to the grid. How can I handle that problem ? Sebastien

Administrator [Syncfusion]
Replied On May 26, 2005 03:55 AM

There are probably several ways to try to handle this. One might be to only call CurrentCell.ConfirmChanges if CurrentCell.IsModified is true. (You wound have to be sure CurrentCell.isModified is only set true in your renderer when the cell is actually modified.)

Sebastien Astie
Replied On May 26, 2005 10:18 AM

Clay, I reverted all my changes back so that it matches the Calendar cell sample again, but the grid does not behave the way it should... There are few things that I do not get: I went through several posts and one of the things mentioned is that you have to explicitly set CurrentCell.IsModified to true; I went through the documentation again and NotifyCurrentCellChanged() is supposed to set that for you. Also I was under the impression that calling NotifyCurrentCellChanged() will also get OnSaveChanges to be fired, which I guess is the assumption in the Calendar cell sample. The sample never calls CurrentCell.ConfirmChanges() If I follow the sample, my problem is that when I click on another row of the cell after editing it the OnSaveChanges doesn''t get fired where as if I leave the grid it does. I am loosing it ? :) Thanks a lot. Sebastien

Administrator [Syncfusion]
Replied On May 26, 2005 01:26 PM

The thing that gets OnSaveChanges called is if CurrentCell.IsModified is true. And calling CurrentCell.NotifyChanged is what is supposed to set CurrentCell.IsModified = true. But calling CurrentCell.NotifyChanged does not directly trigger a call to OnSaveChanges. In standard cells, like a textBox cell, NotifiedChanged is raised everytime you press a key for example, but OnSaveChanges is called when the user leaves the textBox (if IsModified is true). CurrentCell.ConfirmChanges is what actually triggers the call to OnSaveChanges. ConfirmChanges is called after things like CurrentcellValidating is raised. In your case, the reason OnSaveChanges is not call as with the standard cell controls is that NotifyCurrentCellChanged(); is not setting CurrentCell.isModified = true when you call it as you leave teh cell. Here is the code.
public void NotifyChanged()
{
	TraceUtil.TraceCurrentMethodInfoIf(Switches.CurrentCell.TraceVerbose, grid.PaneDesc);
	if (!IsInActiveOrDeactivate)
	{
		IsModified = true;
		Grid.RaiseCurrentCellChanged();
	}
}
Your change event that calls NotifyCurrentCellChanged() does not get raised on every keystroke, and but instead is only being raised as you are leaving the cell, and this is why IsModified was not being set properly in your case. Because of this, I think you will have to either change things so your change event is raised on each keystroke (so things get set before you try to leave the cell), or try to tweak the above suggested code to work around the problems you have found. If you can upload a little sample showing exactly what you want to handle, maybe we can tweak it to get things working.

Sebastien Astie
Replied On May 26, 2005 02:13 PM

Clay, Thanks again for your help, I actually figured out the solution to my problem. Thanks a lot Sebastien

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.

;