Package
caplin.grid.dataprovider

expandable

Provides a standard data provider implementation that enhances the grid by adding the ability to toggle grid rows open or closed. When rows are toggled open or expanded they will push child row data into the grid. Closing them will remove the rows from the grid.

Like normal grids these grids can be defined with an XML definition. The only difference between a normal grid and an expandable one is the use of the ExpandableRowGridDataProvider as the row model data provider. An example of the XML is displayed below:

<grid displayedColumns="description, rate">
 <gridRowModel>
  <expandableRowGridDataProvider>
    <gridDataProvider type="rttpContainerGridDataProvider" container="/CONTAINER/FX/Major"/>
    <childRowDataProvider class="caplin.grid.dataprovider.expandable.ContainerChildRowDataProvider" config="caplinx.grid.dataprovider.expandable.ContainerExpandedRowConfig"/>
  </expandableRowGridDataProvider>
 </gridRowModel>
 <columnDefinitions>
  <column id="description"/>
  <column id="rate"/>
  <column id="size"/>
 </columnDefinitions>
 <decorators>
  <dragDecorator/>
 </decorators>
</grid>

Expandable grids are used to display data that is not provided by a single data provider. For the most part users may not want to see child row data and for that reason it is not included in the underlying data providers row data. There are though circumstances where the user may find it helpful to see data that is not in the used data provider and that is where the expandable grid data provider can be used.

The architecture of the expandable data provider requires that the user configures two sources of data. One is referred to as the 'underlying' data source which provides the data that is displayed when the user first loads up a grid and there are no child rows displayed. This data provider is configured with the <gridDataProvider/> tag. The other data provider is the child row data provider which is configured with the <childRowDataProvider/> tag.

The attributes that can be used in the <gridDataProvider/> tag are 'type' which should be the id of the underlying data provider, in the above case the id is "rttpContainerGridDataProvider", following that attribute should be placed attributes which are to be used in configuring the underlying data provider. From the above case the "container" value will be passed into the underlying data provider.

The attributes that can be used in the <childRowDataProvider/> tag are 'class' which is the class name of the child row data provider, in the above case the class is the caplin.grid.dataprovider.expandable.ContainerChildRowDataProvider, following that is the 'config' attribute which is used to specify a class which is used by the child row data provider to configure several aspects of the child row data such as which container or which fields to request.

The trigger for an expansion is raising a renderer event called 'rowToggle' which can be achieved via a cell renderer handler as demonstrated below.

caplinx.element.handler.ExpandableRowHandler.prototype.onclick = function(oEvent, oRenderer, mAttributes){
 oRenderer.raiseEvent('rowToggle', oEvent);
};

This will initiate a child row data request by the caplin.grid.dataprovider.expandable.ExpandableRowGridDataProvider which asks the child row data provider to retrieve the child row data caplin.grid.dataprovider.expandable.ChildRowDataProvider#getExpandedRowData. Once the data has been retrieved the child row data provider can process it and passes it onto the ExpandableRowGridDataProvider for addition to the grid.

Some of the processing that occurs before the data is passed onto the GridView involves adding useful information to the child row data. This data can be used by stylers or click handlers to style child rows and opened parent rows or handle click actions differently from normal rows.

  Key			Value
- ParentRowId   : parent subject id.
- RowState 	   : expandedRow (expanded parent row) or expandedChildRow (expanded child row) or lastExpandedChildRow (last possible child row).
- ExpandedRowId : child row id, if it doesn't have one of its own this value will be the same as ParentRowId.

So for example a renderer set up like below can be used to style rows differently depending on what type of row they are.

	<renderer name="fx-blotter-expandable">
	 <control name="caplin.control.basic.ExpandableGridRowControl">
		<handler name="caplinx.element.handler.ExpandableRowHandler"/>
	 </control>
	 <downstream>
		<transform name="caplin.element.formatter.NullValueFormatter">
		 <attribute name="nullValue" value=""/>
		</transform>
		<transform name="caplinx.element.styler.FxBlotterExpandableRowStyler">
		 <attribute name="tradingType" value="${TradingType}"/>
		 <attribute name="rowState" value="${RowState}"/>
		</transform>
	 </downstream>
	</renderer>
caplinx.element.styler.FxBlotterExpandableRowStyler.prototype.style = function(vValue, mAttributes, oControl)
	{
		var sTradingType = mAttributes['tradingType'];
		var sRowState = mAttributes['rowState'];
		
		if(sTradingType === 'SWAP')
		{
			if(sRowState === "expandedRow")
			{
				oControl.replaceClass('expandableRow', 'expandableRowExpanded');
			}
			else if(sRowState === '')
			{
				oControl.replaceClass('expandableRowExpanded', 'expandableRow');
			}
		}
		else if(sRowState !== '')
		{
			oControl.addClass(sRowState);
		}
		
	    return vValue;
	};

Constructor Summary

Attributes Name and Description
caplin.grid.dataprovider.expandable()

Method Summary

Attributes Name and Description
<static> void ExpandableGridModelDataAggregator( oChildRowDataProvider, oDataProviderRowModel, sChildRowIdentifier)

The purpose of this class is to aggregate data from the underlying expandable container and the child row data provider.

Constructor Detail

caplin.grid.dataprovider.expandable()

Method Detail

<static> void ExpandableGridModelDataAggregator( oChildRowDataProvider, oDataProviderRowModel, sChildRowIdentifier)

The purpose of this class is to aggregate data from the underlying expandable container and the child row data provider. Once it has all the data it needs - and ONLY then - it commits it to the model. The most important features of this class can be summarized with ACID. ACID -- Atomicity, Consistency, Isolation, Durability The model is never to be changed unless we have every row that should be in view. Each model access/modification MUST leave the model in a consistent state.

Parameters
oChildRowDataProvider
oDataProviderRowModel
sChildRowIdentifier