No announcement yet.

Field color in grid/form

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    If you are in a grid application it should work, but if you have a form (also the editable grid) it will not.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development /


    • #17
      thanks, im using editable grid so that explains my confustion.


      • #18
        Hi all, I am using this JS code to colour an entire row based on a value in a cell. It will check for the right field and then a value in the field. Later I'll probably extend this to use a SQL table so the users can create their own colour filter.

        Put the following in your event onFooter

        echo '<script>
        $("tbody tr td span").each(function() {
        var cellValue = $(this).text();
        var cellName = $(this).attr("id");
        // Call this function as many times as you want. The later calls will override the colour of previous calls.
        // ColourRow parameters - field name to check, field string to check for, value to check, value to check for, colour to change row too.
       $(this), cellName, "visa_type", cellValue, "Follower", "rgb(250, 255, 181)");$(this), cellName, "status", cellValue, "inactive", "rgb(181, 240, 250)");
        function ColourRow (cellName_c, cellName_v, cellValue_c, cellValue_v, colour) {
        // window.alert(cellName_c + cellName_v + cellValue_c + cellValue_v);
        try {
        if ( cellValue_c == cellValue_v && cellName_c.includes(cellName_v) == true ) {
        if ( $(this).parent().attr("class").includes("Odd") == true ) {
        $(this).parent().parent().css("background-color", colour);
        } else {
        $(this).parent().parent().css("background-color", shadeRGBColor(colour, "0.5"));
        } catch(e) {}
        function shadeRGBColor(color, percent) {
        var f=color.split(","),t=percent<0?0:255,p=percent<0?p ercent*-1:percent,R=parseInt(f[0].slice(4)),G=parseInt(f[1]),B=parseInt(f[2]);
        return "rgb("+(Math.round((t-R)*p)+R)+","+(Math.round((t-G)*p)+G)+","+(Math.round((t-B)*p)+B)+")";


        • #19
          I know this is digging up an old thread.... but is there now a more simple way of changing the background color of a field on a form using a condition?