cancel
Showing results for 
Search instead for 
Did you mean: 

checking conditions for a cell in an iGrid

Former Member
0 Kudos

What is the typical javascript to check to see if a cell for a particular row in an iGrid is in spec or out of spec? Also, I will need to change the color of the cell from green to red. I think I know how to do the color, but I am not sure how to do the in spec / out of spec conditions. I have done something like this for a light grid, but it always had 7 records so I was able to specify column 4 row 1 then do this condition. I need to know how to do this when the igrid could contain many records.

Thanks!!

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Can you please be a little bit more specific about what you are trying to do with the out of spec points? From what I understand the Scoreboard mode in the iGrid Display template will take care of coloring individual cell values. You can also create hidden columns of width '0' that will not display be can be used to set colors in the grid as well. Hope this helps.

-Sam

Former Member
0 Kudos

I have an iGrid that has numerous rows of data. One cell will be a results field. This can be found on every row. I also have two cells; one is upper spec and the other is lower spec. I will compare them to the results field. I want out of spec conditions to be red and in spec conditions to be green. I do not want to use lights or scoreboard, just an iGrid.

Former Member
0 Kudos

I would throw your query into an Xacute transaction, adding a column to the outputxml for a inspec/out of spec flag. This column can then be hidden on the grid, but will be very easy to use the standard color contexting feature of the grid.

For instance, let's say your column is named "InSpec". If (lowerspec < results < upperspec), make the InSpec value "Y", if not make it "N". Then in the Grid Template, use the Color Contexting to look for "Y" or "N" and set the colors appropriately.

Former Member
0 Kudos

An alternative to the xacute query is to have an update event on the igrid, and then using javascript to reference the results cell, the lowerspec, and the upper spec cell, set the cell colors. But, I would use the xacute query.

Former Member
0 Kudos

I forgot to consider an Xacute query. Why is this preferred? Performance or because it is easier to manage?

Former Member
0 Kudos

Any time you can take advantage of standard functionality, it is the preferred method. For instance, the iGrid support color contexting based on values (string or numeric) in a column(s). But, the functionality is a bit limited in that it looks for match values for strings and comparisons for numeric.

While it is possible to do what you want using Javascript, it isn't recommended because the applet has to first load and render AND THEN call a javascript function to modify the data and presentation of the applet. Depending on the scenario (number for rows, etc), using javascript to set colors and other attributes may not be as transparent, quick, or smooth as using the standard color contexting that is present when the applet loads (not afterwards).

Although in your case, you'll need to create an xacute query, which may make development more complex, the applet rendering and web page usability will be better.

Also to note, that if your data source is SQL based, you may be able to return the "InSpec" column using a more complex query with perhaps a CASE statement instead of an Xacute transaction.

In any case, when possible, use the features of the applets; don't repeat the functionality with javascript unless you need to.

Also, in terms of business logic or separation of content and logic, if you create the column in the SQL query or Xacute transaction, you're separating the logic from the presentation of the data. Whereas if you create the logic in javascript on the page, it's just another place to perform business logic or rules.

Answers (0)