Announcement

Collapse
No announcement yet.

Field color in grid/form

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Field color in grid/form

    How and where can we set a field value color depending on some conditional statements?

  • #2
    There is a macro where you can set all kind of field properties in a grid. But afaik there's no such thing for forms funny enough.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Ok so this will be a request for forms too.

      Comment


      • #4
        C'mon guys. You don't need a macro for everything do you?

        onLoad: //or wherever you need it
        coloration();

        PHP Method coloration:

        $field = 'invoice_id';
        $color = 'red';
        if({invoice_status} == 1)
        {
        $color = 'green';
        }
        sc_ajax_javascript('set_color',array($field,$color ));

        Javascript Method set_color(field,color):

        document.F1[field].style.backgroundColor = color;

        There you have it, no need to wait and wait and wait ...

        jsb

        Comment


        • #5
          Albert, which macro for grid can do it?

          Comment


          • #6
            @jsbinca nice workaround but all that code can be reduced by a simple macro
            @daretzki sc_field_style,sc_field_color

            Comment


            • #7
              @jsbinca: This is a nice workaround. But afaik F1 is not a constant variable and might change. It requires that before doing this you need to hack into the code to see what variable has been generated? I'm not a javascript guru so I'm not sure. So this little sample is even very helpful for me and I will check this out for sure. Keep in mind that SC is a tool with a broad audience, not everybody is a die-hard programmer. If there are macro's for changing grid fields then it's not logical that there aren't for a form. I never understood that, especially if I see how easy it can be done looking at your sample.
              Albert Drent
              aducom software netherlands
              scriptcase partner, reseller, support and (turn-key) development
              www.scriptcase.eu / www.scriptcase.nl

              Comment


              • #8
                Hi there,
                don't get me wrong, I love the macros and I have a long list what I would like to see realized. Instead of some fancy graphs. :-)

                Albert, I totally agree with you. It is a tool and I would go a little bit further and say it's more a tool box and compared what else is available, a pretty good one (and nothing is perfect).

                Rant mode on
                It is certainly not a box of Lego blocks you somehow stick together and get a masterpiece of art, nor is it an 'eierlegende Wollmilchsau'.
                Rant mode off

                Try to do it on a grid 'by hand' and you understand why there is a macro for this task.
                For a form there is no need for it, because the macro you need is already there: sc_ajax_javascript(), that's it! Think about it. You would save one line of code but loose control.
                And for the Javascript part, I had to look up the name of the attribute I had to set. Don't think of me as a Javascript guru. :-)
                I'm using SC for two years now (popped a bottle of champagne yesterday) and never had a document variable other than F1 for a simple form, so I think it's pretty save to use.
                I'm not sure but I believe having read somewhere in the documentation/samples/knowledge base referring to this variable. And if it changes some day ... yeah.

                This isn't a workaround because there is nothing to work around. (nice pun isn't it?) In the end we are calling ourselves programmer, aren't we?

                Sorry for wandering slightly off topic. :-)

                Comment


                • #9
                  Doesn't matter, I'm happy with the sample. Still think it should be a macro. Not for the one line less code, but for consistancy...
                  Albert Drent
                  aducom software netherlands
                  scriptcase partner, reseller, support and (turn-key) development
                  www.scriptcase.eu / www.scriptcase.nl

                  Comment


                  • #10
                    It is very scary to see that no one actually knows how to change a colour of a field in a form using the scriptcase application. Not even Scriptcase can tell you either! I bought the scriptcase product thinking it could help us in saving development time but now it takes more time in trying to figure out where to put what code in scriptcase for it to work. Scarier is to see the answers given by experts about the usage of scriptcase. Yes I spend one week in reading most of the posts in this forum.

                    sc_ajax_javascript('set_color',array($field,$color )); is a macro????

                    Come on Scriptace - Prove me wrong on my assumption and post your code how to add colour into a field on a certain condition of a FORM not a GRID or Report. I might then use your product in future.

                    Comment


                    • #11
                      Hi jsb
                      Are you not using a macro in your code above? sc_ajax_javascript is a SC macro?

                      Comment


                      • #12
                        Yes, sc_ajax_javascript() is a macro but it does not change the style of a form field and that is what the discussion was about.
                        It calls a javascript function instead, which sets the field color.
                        There is no macro for setting the attributes of form field like the sc_field_style() macro we have for grid fields.

                        jsb

                        Comment


                        • #13
                          Agreed! Thanks jsb

                          Comment


                          • #14
                            I must not understand how the macros are used. I am trying to dynamically change the field text color. I use sc_field_color. I put it under scriptinit event. all I get is....
                            Fatal error: Call to undefined function sc_field_color() in C:\Program Files (x86)\NetMake\v71\wwwroot\scriptcase8\app\project6 \form_dbo_gcFRADDFranchiseeEmail\form_dbo_gcFRADDF ranchiseeEmail_apl.php on line 858

                            where do you put the code to change field color via a macro?

                            thanks

                            Comment


                            • #15
                              if
                              ({freIncludeInDist} =1) { sc_field_color ("Contact/Entity Name", "#006600"); }
                              else
                              { sc_field_color ("Contact/Entity Name", "000000");
                              }


                              above is my code copied directly from the help manual

                              Comment

                              Working...
                              X