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
close icon

GetFormattedText in GridTextBoxCellModel

Hello there,

We have inherited the GridTextBoxCellModel class to expand our formula cell capabilities. We have overriden
GetFormattedText(GridStyleInfo style, object, int)

In this overriden method we are trying to get the

style.FormattedText or style.FormatPreview which has got our main value (6) and not the formula (2*3). This in turn triggers some events in the syncfusion code and GetFormattedText is again called recursively which ends up in StackOverFlow.
We also tried style.GetOffLineCopy() to get the value which didn't help us.
We also tried using the custom FormulaTag, but FormulaTag.Text is not at all refreshed during execution, if we put a break point it gets refreshed or what we have to do is hit the formula engine to get the value which does not suite our requirement.

Can you please let us know how to get the value from this property (sytle.FormattedText) without hitting the same overriden method again (StackOverFlow exception).

This is a major issue for us, kindly do the needful.

Thanks and Regards,
Nevin

5 Replies

NE Nevin February 6, 2007 03:53 PM UTC

Just for your information we are using 4.3 version of Syncfusion.

Regards,
Nevin


AD Administrator Syncfusion Team February 6, 2007 07:12 PM UTC

Hi Nevin,

You can use the base.GetFormattedText() method to get the formatted text in a GetFormattedText override method of the derived GridTextBoxCellModel class. Here is a code snippet.

public class MyTextBoxCellModel : GridTextBoxCellModel
{
public MyTextBoxCellModel(GridModel grid): base(grid){}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{ return new MyTextBoxCellRenderer(control, this);}
public override string GetFormattedText(GridStyleInfo style, object value, int textInfo)
{
string FormattedText = base.GetFormattedText (style, value, textInfo);
Console.WriteLine(FormattedText);
return FormattedText;
}
}
public class MyTextBoxCellRenderer : GridTextBoxCellRenderer
{
public MyTextBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel) : base(grid, cellModel)
{
this.SupportsFocusControl = true;
this.SupportsEditing = true;
}
}

Best Regards,
Haneef


NE Nevin February 7, 2007 09:01 AM UTC

Hi Haneef,
Thank you for the quick response.
We had tried this option earlier base.GetFormattedText() but this will return the same text as style.Text. In our case it returns the Formula (2*3) and not the value (6).

We had a look into the base class where we found that it is raising
Grid.RaiseQueryCellFormattedText(ea);
if (ea.Handled)
return ea.Text;
and returning the Text rather than FormatValue which is the last line of the GridTextBoxCellModel :: GetFormattedText(..)

Is there any other work around to get the value which is present in style.FormattedText or style.FormatPreview.

Regards,
Nevin


NE Nevin February 14, 2007 06:42 AM UTC

Hello Haneef,

The problem mentioned above is quite critical to our project and needs to be resolved ASAP. Can you kindly let us know the status. Kindly advice in case we need to submit this issue in direct-trac.

Looking forward to your reply.

Regards,
Nevin


AD Administrator Syncfusion Team February 14, 2007 11:49 PM UTC

Hi Nevin,

My apologizes for the delay caused on this issue.

Please try the attached sample and let me know if this helps.
FormulaCellModel.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon