How to color grid cells according to properties that are hidden in grid?

Hi Community,

I hope somebody can give me some hints to solve the following use case.

I use an onAfterGet Server Method in ItemType Part that colors certain columns like ‘state’. Now I want to add some color to an additional property that contain the ERP-Number of a Part.

The ERP-Number column shall be colored according to two other properties that give information about the state of the erp transfer. But I don´t want to display the two additional properties in the main grid. That´s why the two properties are hidden by default.

This now leads to the following problem. When my two state properties are hidden, they are not part of the get query that is run when performing a simple search in the Part grid. When the properties are not selected in with the get query, I cannot use them for coloring with my onAfterGet method. Is it somehow possible to add the two properties to the grid select query, but without showing the properties in the grid?

Or does anybody now other ways to add some color to grid cells? I am thinking about some federation approach, but maybe this one can be solved easier. Thanks for any help!

Best regards,
Angela

  • Hi Angela,

    I'm not sure there's a built-in way to configure adding two properties to the select statement without exposing them on the main grid. As a programmatic approach, you could use an onBeforeGet server method to check the select attribute for the two properties you need and add them to the select attribute if they're not found. This should ensure that the properties are available in your onAfterGet.

    Chris

  • Hi Chris,

    thanks for the fast answer! I made a quick test and can confirm that the basic concept with an onBeforeGet Method works excellent. 

    I used the following query to overwrite the original get query used for the grid:

    string newSelect = this.getAttribute("select") + ",myproperty1,myproperty2";
    this.setAttribute("select", newSelect);
    return this;

    In my case I always need the additional properties so the hard coded approach should to the job. It maybe only contains a high risk of being forgotten :).

  • Ok, quick update. The Method only works works well in the grid, but leads to an error message as soon as you open a Part with a BOM.

    --> Value cannot be null. Parameter name: key

    I remember that I have another Method to hide some EOL Parts in the grid where I use some extra code so the Method is not run in relationships. But for this use case I would be helpful to have the ERP status in Part BOM grid too. Do I have to use a similiar onBeforeGet query in ItemType Part BOM or is there a better solution available?

  • Hi community,

    I am reopening this issue cause I am still look for a proper solution for this task. Coloring cells according to hidden properties could be a real powerful way to highlight data.

    I made some tests with a custom variant that shows icons instead of colors. This would give us a lot of ways to keep the grid compact while still presenting all information of interest for the end user:

    While I was successful to display custom icons in the cell without performance issue, I still face the same error message when opening a BOM.

    I am right now look for a solution to overwrite the select query on form open. Maybe someone wants to join this project and has an idea?

    Angela

  • Hey , I've followed you Git examples for the coloration and really appreciate your sharing of those!  Is is possible to give an example of how you got an Icon like the above?  Thanks in advance!

  • I cannot share the solution, but it´s simply a CSS hack. CSS can be used for all kind of designs. Your favorite search machine helps. :)