How to color full federated items in the grid?
- 7 years ago
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 viewAML += "</Result></SOAP-ENV:Body></SOAP-ENV:Envelope>";
Item iRes = inn.newItem();
iRes.loadAML(AML);return iRes;