SMART datagrid v.1 > Examples

Back  Forward

Cell Merging  Example

You can merge and display one or more neighboring cells contained in the same column. The criteria of merging the cells is the result value of the expression specified in ValueColumn.mergeExpression property. In other words, if calculate each row with the expression and the value is the same as the prior cell, these two cells will be displayed after binding. If SMART datagrid expression is not enough to use, you can also specify JavaScript callback function in mergeCallback property. 

Code -1
    var col = grid.columnByName('Country');
    col.setMergeExpression('value');
    // or, JavaScript callback
    col.setMergeCallback(function (item, column) {
        // If it is a grid which will be exported to a report, you should find it out regionally rather than using global grid variable.
        return column.grid().getValueAt(item, column + grdMain.getValueAt(item, 'flow');
    });
Grid - 1
rows

In the "Country_2" column, it only displays the first letter of the country name in the cell. However, you can specify the value differently in the merged cell through ValueColumn.mergeValueCallback or ValueColumn.mergeValueExpression. If both properties are not specified, it will display the value of the first row contained in the merging. 

Code -2
    var col = grid.columnByName('Country2');
    col.setMergeCallback(function (item, column) {
        return grdMain.getValueAt(item, column).substr(0, 1);         		    
    });
    col.setMergeValueCallback(function (item, column, value) {
        return value.substr(0, 1);            		    
    });

View Source JSP 

See Also
ValueColumn.mergeExpression
ValueColumn.mergeCallback
ValueColumn.mergeValueExpression
ValueColumn.mergeValueCallback
SMART datagrid Expression Overview
Examples
Cell Merging2