Search Flex Components Free

Custom Search

December 20, 2007

Flex Control DataGrid Non-editable Column Source Code Sample

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundAlpha="0" creationComplete="srv.send()" >
<mx:Script><![CDATA[
import mx.controls.DataGrid; import mx.events.DataGridEvent;
private function initDataGrid() : void { myGrid.dataProvider = srv.lastResult.catalog.product; }
private function verifyEdit(event:DataGridEvent) : void { if(event.dataField == 'price') { event.preventDefault(); } }
]]></mx:Script>
<mx:HTTPService id="srv" url="../assets/catalog.xml" useProxy="false" result="initDataGrid()"/>
<mx:Text width="550" text="In this example, although the Datagrid is editable, we are using the itemEditBeginning event to prevent the editing of the 'Price' column." />
<mx:Text id="text1" width="200" color="0xFF0000" />
<mx:DataGrid id="myGrid" editable="true" width="450" height="300" itemEditBeginning="verifyEdit(event)" > <mx:columns> <mx:DataGridColumn dataField="price" headerText="Price (non-editable)"/> <mx:DataGridColumn dataField="name" headerText="Product" /> </mx:columns></mx:DataGrid>
</mx:Application>

Related Flex Tutorials