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

SaveCellInfo Not firing

Hi,

My set up is:
-Inherited grid control that handles the SaveCellInfoEvent of the grid.
-Inherited GridFormulaCellModel and GridFormulaCellRenderer that formats the cell by setting the .Text property of the e.Style argument in OnPrepareViewStyleInfo method of the renderer.
-Custom cell model is registered as "MyType" in the grid.
-ForceSaveCellInfo of Engine is set to true.

My problem is this:
-I have a cell of type "MyType" with a formula say "=A1+A2"
-If I change A1 or A2 value of the formula does not change.

I have found the following:
-when the custom renderer is changed so that it does not set the .text property, the SaveCellInfo event of the grid fires for the formulae cell (when A1 or A2 is changed).
-when the custom renderer tries to set the .text property, the SaveCellInfo event of the never fires for the formulae cell.
-This seems to be the problem as the value I am using to set the formatted value in the renderer comes from a custom property that is set in the SaveCellInfo event. If it is not fired then it will always be the same.

Why? What am I doing incorrectly.

Note that the custom format I am trying to achieve is a percent format without the percent sign so that a cell with .value = 0.10 is displayed as "10.00".

2 Replies

AD Administrator Syncfusion Team October 4, 2007 11:44 AM UTC

I tried to set up a sample to see the problem you are describing. I derived the GridControl and overrode OnSaveCellInfo. I also derived the formulacellmodel and formulacellrenderer. In the renderer, I overrode OnPrepareViewStyleInfo and performed some trivial formatting there by changing e.Style.Text.

In my sample, I did not see a problem with the formula (=A1+A2) updating when you changed either A1 or A2. And grid.OnSaveCellInfo was also being hit.

Bu what I did see was that the renderer.OnPrepareViewStyleInfo was not being hit for the cell that held the formula =A1 + A2. So, the formatting done in OnPrepareViewStyleInfo was not applying to the cell holding the formula. (When I changed the non-formulacells, A1 or A2, OnPrepareViewStyleInfo was hit for these cells, but not for the cell containing the formula.)

Is this the problem you are referring too? If so, I think you can work around it by doing the formatting in the grid's DrawCellDisplayText event instead on teh renderer.OnPrepareViewStyleInfo. Attached is the sample with the renderer code set up to listen to the grid's DrawCellDisplayText. With this code, the formatting is seen in all the cells, A1, A2, and the cell holding the formula.

CustomFormulaRenderer.zip


SM Stephen Main October 5, 2007 06:36 AM UTC

Thanks Clay,

I have received a solution to this from your colleague Fahad in DirectTrac. The attached sample demonstrates my problem in that that the Save cell info event did not fire for the formula cell.

However if I replace the line:
(person.TestScorePercentage).ToString("00.00");

with:
e.Style.Text = e.Style.FormattedText;
e.Style.Text = (person.TestScorePercentage).ToString("00.00");

The event is successfuly celled. I have copied the explanation below:

------------------------
This is because the formula cell C3 requires input in the format of "=D3+D4".

For example , If you set e.Style.Text as e.Style.CellValue, Essential Grid will display the expected result .

Case 1: When e.Style.Text = e.Style.CellValue
Since C3 is a formula cell it receives input as "=D3+D4" , so we get the expected result.

Case 2 : When e.Style.Text = person.TestScorePercentage
C3 takes input as previous numeric value say 30 and not the formatted cell value.

So we format the e.Style.Text , desired result will be displayed.
------------------------

Hope this might save somebody else some hours.

Thanks,
Steve

SaveCellInfoProblem.zip

Loader.
Live Chat Icon For mobile
Up arrow icon