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

Custom Renderer OnSaveChanges not called with GDBG in 1.6.1.8

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

10 Replies

AD Administrator Syncfusion Team May 18, 2005 06:17 PM UTC

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.


SA Sebastien Astie May 18, 2005 10:22 PM UTC

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.


AD Administrator Syncfusion Team May 18, 2005 11:59 PM UTC

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();
		}
	}
}


SA Sebastien Astie May 19, 2005 05:34 PM UTC

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


AD Administrator Syncfusion Team May 19, 2005 06:40 PM UTC

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.


SA Sebastien Astie May 26, 2005 01:41 AM UTC

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


AD Administrator Syncfusion Team May 26, 2005 07:55 AM UTC

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.)


SA Sebastien Astie May 26, 2005 02:18 PM UTC

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


AD Administrator Syncfusion Team May 26, 2005 05:26 PM UTC

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.


SA Sebastien Astie May 26, 2005 06:13 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon