How to use the Consultingwerk.Windows.Util.UltraFormulaBuilderHelper
 
Forums / SmartComponent Library - Developer Forum / How to use the Consultingwerk.Windows.Util.UltraFormulaBuilderHelper

How to use the Consultingwerk.Windows.Util.UltraFormulaBuilderHelper

3 posts, 0 answered
  1. Carl Verbiest
    Carl Verbiest avatar
    67 posts
    Registered:
    12 Oct 2018
    11 Jul 2019
    Link to this post
    I found the Consultingwerk.Windows.Util.UltraFormulaBuilderHelper but I can't find any code using it.

    I'd like to start UltraFormulaBuilderHelper from our column chooser to edit/ add formulas on a grid but I find that the grid CalcManager only has AddFormula and no apperant way of getting to the existing formula's.

    Is there some sample code available on how this can be used .
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    11 Jul 2019 in reply to Carl Verbiest
    Link to this post
    We have an example where we're using the UltraFormulaBuilderHelper to edit the formular used as a named reference of the calc-manager. I don't have experience using this with Grid cells.

            Consultingwerk.Windows.Util.UltraFormulaBuilderHelper:ShowFormulaBuilderDialog (ultraCalcManager1:NamedReferences["name-color":U]) .

    The named reference is defined in the UltraCalcManager:

            DEFINE VARIABLE arrayvar1 AS System.Object EXTENT 1 NO-UNDO.
            arrayvar1[1] = NEW Infragistics.Win.UltraWinCalcManager.NamedReference("name-color":U, "if(len([//name]) < 5 , ~"error~" , ~"default~" )":U, ?, ?).
            THIS-OBJECT:ultraCalcManager1:NamedReferences:AddRange(arrayvar1).

    and then we're monitoring the ResultChanded event and act accordingly

        METHOD PRIVATE VOID ultraCalcManager1_NamedReferenceResultChanged (INPUT sender AS System.Object, INPUT e AS Infragistics.Win.UltraWinCalcManager.NamedReferenceResultChangedEventArgs):

            DEFINE VARIABLE cColor AS CHARACTER NO-UNDO.

            IF e:NamedReference:Key = "name-color":U THEN DO:

                IF TYPE-OF (e:NamedReference:FormulaResult:Value,
                            Infragistics.Win.CalcEngine.UltraCalcErrorValue) THEN
                    RETURN .

                ASSIGN cColor = STRING (UNBOX (e:NamedReference:FormulaResult:Value)) .

                IF cColor = "default":U THEN
                    smartBusinessEntityBindingSource1_eCustomer_Name:StyleSetName = Infragistics.Win.AppStyling.StyleManager:GetDefaultStyleSetName ("":U) .
                ELSE
                    smartBusinessEntityBindingSource1_eCustomer_Name:StyleSetName = cColor .
            END.

            CATCH err AS Progress.Lang.Error :
                Consultingwerk.Util.ErrorHelper:ShowErrorMessage (err) .
            END CATCH.

        END METHOD .



  3. Carl Verbiest
    Carl Verbiest avatar
    67 posts
    Registered:
    12 Oct 2018
    11 Jul 2019 in reply to Mike Fechner
    Link to this post
    Ok, thanks.

    My use case is to display a field (inttime) that contains seconds since midnight as a time string.

    I created a sample in C# following https://www.infragistics.com/help/winforms/wincalcmanager-creating-a-calculated-column-in-wingrid
    The resulting C# code for a calculated column isInfragistics.Win.UltraWinGrid.UltraGridColumn.
    ultraGridColumn3 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("UnboundColumn1", 0);
           // ultraGrid1
           this.ultraGrid1.CalcManager = this.ultraCalcManager1;
           this.ultraGrid1.DataSource = this.ultraDataSource1;
           ultraGridColumn1.Header.VisiblePosition = 0;
           ultraGridColumn2.Header.VisiblePosition = 1;
           ultraGridColumn3.Formula = "dateadd('s',[inttime], today())";
           ultraGridColumn3.Format = "hh:mm";
           ultraGridColumn3.Header.VisiblePosition = 2;

    I'll see how we can best integrate this into our BrowseRenderer

    Last modified on 11 Jul 2019 13:07 by Carl Verbiest
3 posts, 0 answered