This article explains some technical aspects that are worth taking into consideration when creating grid definitions. 


Logical Expressions in TextColumns 

As the grid component works today, the content of a cell in a configured grid when viewed by users is the result of a calculation. This is what makes the values visible. Given this, evaluating logical expressions in TextColumns that involve a lot of data may heavily affect performance for the user when they are scrolling in the grid. The below definition, for example, will potentially affect performance negatively when being viewed if the amount of data is large:


Example Definition

<Grid>
  <Variable name="variableWithLotsOfData" select="/9IES/9ICF/ARSC/ARCW" as="Items"/> 
  <Columns>
    <ItemNameColumn width="200" /> 
    <TextColumn caption="HeavyOperationColumn">
      <ColumnVariable name="lotsOfData" select="$variableWithLotsOfData" as="Items"/>
      <Value>#{?if . in $lotsOfData/ARRP then 'OK' else 'Not OK'}</Value>
    </TextColumn>        
  </Columns>

  <ForEach select="/9IES/9ICF/ARSC/ARCW/ARPP">
    <Row/> 
  </ForEach>
</Grid>


Example Output

Note: The above grid definition only shows the principal problem. There is an obvious optimization in moving the calculation in "$lotsOfData/ARRP" to the select expression for the variable "variableWithLotsOfData". Normally in these scenarios, these expressions are much more complex. However, for the sake of simplicity we will not expand the example further.


For every row, the calculation for the expression in the "Value" tag is evaluated, meaning that the expression "if . in $lotsOfData/ARRP then 'OK' else 'Not OK'" will be reevaluated for every cell every time it becomes visible. 


The below grid definition produces a similar result, but with a much better performance for large amounts of data:


Example Definition

<Grid>
  <Variable name="variableWithLotsOfData" select="/9IES/9ICF/ARSC/ARCW" as="Items"/> 
  <Columns>
    <ItemNameColumn width="200" /> 
    <TextColumn caption="NoOperationColumn" objectName="notOk">Not OK</TextColumn>        
  </Columns>

  <ForEach select="/9IES/9ICF/ARSC/ARCW/ARPP">                                      
    <Variable name="lotsOfData" select="$variableWithLotsOfData/ARRP" as="Items"/>
    <Row>
      <If test="not . in $lotsOfData">
        <RowObject name="notOk"/>
      </If>  
    </Row>   
  </ForEach>
</Grid>


Example Output


In this example, we have moved the evaluation of the results outside the column itself, only printing information when something is wrong by using the "RowObject" tag instead of the complex expression in the "TextColumn" from the previous example. This results in the calculation of the variable "lotsOfData" potentially occurring fewer times than before, resulting in a faster generation of the grid in the client. Also, since the expression evaluation in the "TextColumn" is just a string, the cost of fetching the cell value when the cell becomes visible is very small.


Grid Optimized Setting

To address the affect on performance described above, the <Grid> tag has an optional optimized attribute to define whether or not each cell value will be recalculated as needed as you work or only one time (when you load the grid). See Configuring Tables and Grids for more information.


CellAutoHeight

The option "CellAutoHeight" is normally used when displaying "DescriptionColumn" or other columns with a lot of data. However, this option should only be used when it is necessary since it does have a significant performance impact for grids with a large amount of data.  If the purpose of a grid is only to export it to Excel, we recommend not using "CellAutoHeight".