Announcement

Collapse
No announcement yet.

Field color in grid/form

Collapse
X
  • 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
    www.scriptcase.eu / www.scriptcase.nl

    Comment


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

      Comment


      • #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

        Code:
        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.
        
        ColourRow.call($(this), cellName, "visa_type", cellValue, "Follower", "rgb(250, 255, 181)");
        ColourRow.call($(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)+")";
        }
        
        
        </script>
        ';

        Comment

        Working...
        X