Forum Discussion

team_aras_meupe_com's avatar
3 years ago
Solved

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 angela​ 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;
  • 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. :)

3 Replies

  • 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. :)

    • team_aras_meupe_com's avatar
      team_aras_meupe_com
      Creator III

      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

      [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:d322febe-6098-4206-bb7a-97261e4acb8e:type=text&text=for%20%28int%20i%20%3D%200%3B%20i%20%3C%20this.getItemCount%28%29%3B%20i%2B%2B%29%0A%7B%0A%20%20%20%20string%20bg_color_state%3B%0A%20%20%20%20string%20myCss%20%3D%20%22%22%3B%0A%20%20%0A%20%20%20%20Item%20thisItem%20%3D%20this.getItemByIndex%28i%29%3B%0A%20%20%20%20%0A%20%20%20%20bg_color_state%20%3D%20%22%23FFFFBB%22%3B%20%2F%2F%20light%20yellow%0A%20%20%20%20%0A%20%20%20%20myCss%20%3D%20%20%22.mp_lpve%20%7B%20background-color%3A%20%22%20%2B%20bg_color_state%20%2B%20%22%20%7D%20%22%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%22.mp_necesidad_id%20%7B%20background-color%3A%20%22%20%2B%20bg_color_state%20%2B%20%22%20%7D%20%22%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%22.mp_rm_hijo_id%20%7B%20background-color%3A%20%22%20%2B%20bg_color_state%20%2B%20%22%20%7D%20%22%2B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%22.mp_rm_father_id%20%7B%20background-color%3A%20%22%20%2B%20bg_color_state%20%2B%20%22%20%7D%20%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%2F%2F%20myCss%20%3D%20%22.mp_lpve%2C%20.mp_necesidad_id%20%7B%20background-color%3A%20%22%20%2B%20bg_color_state%20%2B%20%22%20%7D%22%3B%0A%20%20%20%20thisItem.setProperty%28%22css%22%2CmyCss%29%3B%0A%7D%0A%0Areturn%20this%3B]

      Too many thanks!!!

      • angela's avatar
        angela
        Catalyst II

        Aaahh, the beautiful piss yellow. The color of choice [emoticon:d6dd260102fd406884fc96b8bc59760b]

        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 + ";}";