How do i make some of my datagridcolumns non editable or readonly if my flex datagrid is editable?
views:
34answers:
1
Q:
How do i make some of my datagridcolumns non editable or readonly if my flex datagrid is editable
+2
A:
DataGridColumn
has property editable
. Just set it to false
.
See the documentation for DataGridColumn.
Here is a quick example of a DataGrid with one editable column:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:DataGrid id="testGrid" editable="true">
<mx:columns>
<mx:DataGridColumn headerText="Column1" dataField="column1" editable="false" />
<mx:DataGridColumn headerText="Column2" dataField="column2" />
</mx:columns>
<mx:dataProvider>
<mx:ArrayCollection>
<mx:Object>
<mx:column1>Some Value</mx:column1>
<mx:column2>Some Other Value</mx:column2>
</mx:Object>
</mx:ArrayCollection>
</mx:dataProvider>
</mx:DataGrid>
</mx:Application>
The first column is not editable, the second one is.
Carlos
2010-10-13 09:47:28
Thank you but it doesnt seem to be working in which event handler should i specify which columns should be readonly?
Linda
2010-10-13 10:15:31
@Linda I think you need to give a bit more information. Setting the editable properties of the datagrid and column is the way to make some of the columns non-editable. If this is done in the MXML, it should not involve any event handlers. Can you edit your original question with an example how you are defining your datagrid and trying to set the editable property?
Carlos
2010-10-13 10:22:59
I edited my answer to include an example.
Carlos
2010-10-13 10:31:55
<mx:DataGrid x="31" y="9" width="1000" height="600" id="dgViewPreview" visible="true" itemEditEnd="dgViewPreview_itemEditEndHandler(event);Calculate()"> </mx:DataGrid>
Linda
2010-10-13 11:07:48
I have a function that does the databinding. My column names and number of columns change all the time so i cant specify the editability like in your example.
Linda
2010-10-13 11:12:29
@Linda Based on the information you have given, it is hard to say how you should implement this. However, since this is only about setting one property for the column, it should not be too difficult to do wherever you need to do it. For better answer I would have to know exactly what you are trying to do and what your requirements are.
Carlos
2010-10-13 11:32:44