background-color in TOC

Hello, I am trying to change the background color of a cell in the TOC. I have based on AngelaP's code in git, but I can't change anything. Any suggestions?

My ARAS is version 11.0 SP9

This is  GItHub: Impact Matrix Color


for (int i = 0; i < this.getItemCount() - 1; i++)
{
    // Declaración de variables
    string bg_color_state;
    string myCss = "";

    // Obtener el elemento en la posición i
    Item thisItem = this.getItemByIndex(i);

    // Obtener el valor de la propiedad "mp_lpve_posicion" del elemento actual
    string thisStatus = thisItem.getProperty("mp_lpve_posicion", "");

    // Establecer el color de fondo del estado en "#FFFFBB" (amarillo claro)
    bg_color_state = "#FFFFBB";

    // Construir una cadena de estilo CSS para el elemento actual
    myCss = ".state { background-color: " + bg_color_state + " }";

    // Establecer la propiedad "css" del elemento actual con la cadena de estilo CSS
    thisItem.setProperty("css", myCss);
}

// Devolver el objeto actual
return this;

Parents
  • The sample is a bit buggy I so far haven´t updated it. 

    Don´t use the -1 in the for loop -> for (int i = 0; i < this.getItemCount(); i++)

    If you want to color a custom property, you have to change the "mycss"-part -> so instead of .state use .mp_lpve_posicion . 

    The sample is basically a C# variant of the common VB solution in this forum. Color schema is optimized for Innovator 11, for Innovator 12 I would use different colors that are a bit stronger. :)

  • Yess, too many thanks!!! it works fine:

    This is how the code has remained. What I have not been able to is to group the attributes in a single line. commented line number 15

    for (int i = 0; i < this.getItemCount(); i++)
    {
        string bg_color_state;
        string myCss = "";
      
        Item thisItem = this.getItemByIndex(i);
        
        bg_color_state = "#FFFFBB"; // light yellow
        
        myCss =  ".mp_lpve { background-color: " + bg_color_state + " } "+
                 ".mp_necesidad_id { background-color: " + bg_color_state + " } "+
                 ".mp_rm_hijo_id { background-color: " + bg_color_state + " } "+
                 ".mp_rm_father_id { background-color: " + bg_color_state + " } ";
                 
    // myCss = ".mp_lpve, .mp_necesidad_id { background-color: " + bg_color_state + " }";
        thisItem.setProperty("css",myCss);
    }
    
    return this;

    Too many thanks!!!

  • Aaahh, the beautiful piss yellow. The color of choice Joy

    I agree the grouping doesn´t work. I don´t know why, I would prefer to group the CSS classes too. CSS itself supports this, but Innovator don´t.

    Some hint: The CSS property can store only limited content. Remove all spaces you don´t need. Close each class section with a semicolon “;”.  Keep it as compact as possible.

    Something like this ->  newCss = ".state{font-color:" + bg_color_state + ";}";

Reply
  • Aaahh, the beautiful piss yellow. The color of choice Joy

    I agree the grouping doesn´t work. I don´t know why, I would prefer to group the CSS classes too. CSS itself supports this, but Innovator don´t.

    Some hint: The CSS property can store only limited content. Remove all spaces you don´t need. Close each class section with a semicolon “;”.  Keep it as compact as possible.

    Something like this ->  newCss = ".state{font-color:" + bg_color_state + ";}";

Children
No Data