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?