Answered by:
How to edit data in datagrid?

Question
-
Hi everyone,
I am using MVVM pattern,i have a datatable which has some data and it is bind to a datagrid. Now i want to edit some data inside my datagrid at run time and according to that changes i want to update my collection,i know it can be done by putting columns editable. But my problem is that there is three columns in my datatable which i dont want to edit at runtime,and columns in datagrids are autogenerated because data in the data table is not predictable. So how to do it? please help me .
Thanks in advance
Tuesday, December 21, 2010 8:57 AM
Answers
-
If you using AutGenerate columns, it will make the column not editable if the property is ReadOnly. This may or may not be something you can change, but thought I'd throw that out there.
- Proposed as answer by Sheldon _Xiao Tuesday, January 4, 2011 4:38 AM
- Marked as answer by Sheldon _Xiao Sunday, January 16, 2011 5:26 AM
Tuesday, December 21, 2010 1:45 PM
All replies
-
<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>If you know the names of the columns that are auto generated then you should be able to add editable="false" in code behind if you create it in code behind
John F LundyTuesday, December 21, 2010 9:15 AM -
Thanks for reply, but as i mention in my post that my data is unpredictable and also i am using MVVM so i cant write any thing in code behind?
Tuesday, December 21, 2010 9:27 AM -
Sorry missed the MVVM line. Hope you get your answer soon.
John F LundyTuesday, December 21, 2010 9:44 AM -
If you using AutGenerate columns, it will make the column not editable if the property is ReadOnly. This may or may not be something you can change, but thought I'd throw that out there.
- Proposed as answer by Sheldon _Xiao Tuesday, January 4, 2011 4:38 AM
- Marked as answer by Sheldon _Xiao Sunday, January 16, 2011 5:26 AM
Tuesday, December 21, 2010 1:45 PM -
Hi Apoorv_Jain,
Could you tell me the situation of your issue?
Sheldon _Xiao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Wednesday, December 29, 2010 11:53 AM