How to color full federated items in the grid?

Hi,

maybe somebody has an idea how to solve this one. I have a full federated ItemType that contains a couple of yes/no columns. The data is displayed as standard grid in Aras. I want to highlight the yes/no values in the grid.

Coloring regular ItemTypes is possible with an onAfterGet Method that overwrites the CSS property. There are samples available in this forum that show how to do it. 

But this approach doesn´t work for full federated Items, as the physical table inside Aras is empty and we just lock at datasets from another database.

I already discovered, that I can fill the Aras 'CSS'  property in the SQL-view that I use for quering the data. But unfortunately, my current SQL view is very complex. I would have to do a lot of SQL queries for building the correct stylesheet string for the CSS property column. 

Does anybody know a simpler approach to solve this use case?

Thanks for any feedback!
Angela

  • I have had the same requirement, I queried the SQL as normal. but I processed the result to add the CSS to the returned AML.

    This is an extract of my code, it shows you the process I used (note this will need to be edited to provide the desired results):

    //sRes is an item representing the result of my SQL, perform the query here

    string AML = "";
       AML += "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:i18n=\"http://www.aras.com/I18N\"><SOAP-ENV:Body><Result>";


    if (sRes.getItemCount() < 1)
    {
       AML += "<Item type=\"Activity2\" action = \"get\" id=\"" + "No Results" + "\">";
       AML += "</Item>";
    }
    else if (sRes.getItemCount() > 1000)
    {
       AML += "<Item type=\"Activity2\" action = \"get\" id=\"" + "Too Many Results" + "\">";
       AML += "</Item>";
    }
    else
    {
    for (int i = 0; i < sRes.getItemCount(); i++)
    {
        string rw1 = sRes.getItemByIndex(i).getProperty("a2id",i.ToString() + ". Unable to Promote Multiple Items")

    //Get the Yes/No values
        string act2_pending = sRes.getItemByIndex(i).getProperty("act2_pending","");
        string act2_active = sRes.getItemByIndex(i).getProperty("act2_active","");
        string act2_drafted = sRes.getItemByIndex(i).getProperty("act2_drafted","");
        string act2_supplier = sRes.getItemByIndex(i).getProperty("act2_supplier","");
        string act2_manager = sRes.getItemByIndex(i).getProperty("act2_manager","");
        string act2_complete = sRes.getItemByIndex(i).getProperty("act2_complete","");
        string act2_notrequired = sRes.getItemByIndex(i).getProperty("act2_notrequired","");
        string act2_mp_pic = sRes.getItemByIndex(i).getProperty("act2_mp_pic","");
        string act2_mp_mgr = sRes.getItemByIndex(i).getProperty("act2_mp_mgr","");

        AML += "<Item type=\"Activity2\" action = \"get\" id=\"" + rw1 + "\">";



    //AML is a string representing the AML to be returned
        AML += "<Item type=\"Activity2\" action = \"get\" id=\"" + rw1 + "\">";

    //...
    //populate the AML Item
        AML += "<act2_drafted>" + act2_drafted + "</act2_drafted>";
        AML += "<act2_supplier>" + act2_supplier + "</act2_supplier>";
        AML += "<act2_manager>" + act2_manager + "</act2_manager>";
        AML += "<act2_complete>" + act2_complete + "</act2_complete>";
        AML += "<act2_notrequired>" + act2_notrequired + "</act2_notrequired>";
        AML += "<act2_mp_pic>" + act2_mp_pic + "</act2_mp_pic>";
        AML += "<act2_mp_mgr>" + act2_mp_mgr + "</act2_mp_mgr>";
    //...

    //CSS represents the fields that should be populated (note: these properties are Boolean "1" or "0").
        string CSS = "<css>";
        if (act2_pending !="0") CSS += ".act2_pending{background-color:PINK;};";
        if (act2_active !="0") CSS += ".act2_active{background-color:Tomato;};";
        if (act2_drafted !="0") CSS += ".act2_drafted{background-color:DarkOrange;};";
        if (act2_supplier !="0") CSS += ".act2_supplier{background-color:Thistle;};";
        if (act2_manager !="0") CSS += ".act2_manager{background-color:Gold;};";
        if (act2_complete !="0") CSS += ".act2_complete{background-color:LawnGreen;};";
        if (act2_notrequired !="0") CSS += ".act2_notrequired{background-color:Silver;};";
        if (act2_mp_pic !="0") CSS += ".act2_mp_pic{background-color:Plum;};";
        if (act2_mp_mgr !="0") CSS += ".act2_mp_mgr{background-color:Plum;};";
        CSS += "</css>";
        AML += CSS;
        AML += "</Item>";
    }

    //return the AML as an item collection to view

    AML += "</Result></SOAP-ENV:Body></SOAP-ENV:Envelope>";

    Item iRes = inn.newItem();
    iRes.loadAML(AML);

    return iRes;

  • Many thanks! Didn´t know that this is possible!

    I solved my current use case with a subquery on SQL level that helped me to build the css property more easily. I just had a couple of columns with yes/no values, so there weren´t much variants to care for.

    I wonder if your concept might also work to color tree grid views? Just a quick idea...

  • Not sure how you would go about doing that... 

    Tree grid does not use the standard grid, it uses a separate HTML page to generate a view. eg /Modules/aras.innovator.TreeGridView/Views/MainPage.html you would have to ensure any css field was being interpreted correctly by this page (and not being overridden elsewhere).

    This also means that many of the more useful features are not available are not available (e.g. search, order by, hide columns).

    Many thanks,
    Martin