Forum Discussion

ashishraj14_1's avatar
ashishraj14_1
New Contributor
15 years ago

DataGrid itemrenderer - unable to modify an existing cell value

Hi there,



I have tried all the possible combinations on how to set a cell value of a column contained within a DataGrid.

The object I am trying to work with looks like this...

Browser.AdminPage.Settingsform.Datagrid.listbasecontentholder.datagriditemrenderer

baiscally its a datagrid and some columns have itemrenderers to select value from a dropdown list....



I have a datagrid which has 7 rows and 2 columns  & the cell value wghich I am trying to modify is a datagriditemrenderer object 

I am using the following code

 

==================================

rcount = dataGrid.wRowCount

ccount = dataGrid.wColumnCount

for i = 0 to rcount-1

for j = 0 to ccount-1

tmp = dataGrid.wValue(i,j)

MsgBox tmp

if (tmp = "xyz")Then

dataGrid.wValue(i,j) = "New Value"

End If

next

next

============================================

I am able to get the old value and replace it with the new value. Problem I am runing into is ,when I click 'Save' button in the app, the new value does not get saved :(

Is there any other way to set/modify the cell value is a datagriditemrenderer?



Many thanks in advance.

cheers,

Ash

1 Reply

  • Hi Ashish,



    You seem to have faced a limitation with using the wValue property to set values in Flex mx DataGrid controls:



    If the grid is bound to a “raw” data object, such as Array, XML or XMLList, assigning a value to the wValue property changes only the cell’s display value but does not modify the grid’s underlying data source. In this case, the displayed value is reset the original value once the grid refreshes.



    To change cell values in an editable grid, simulate actual input into in-place editors. For example, use the ClickCell action to activate the in-place editor, then simulate entering or selecting a new value, and then use Keys("[Enter]") to commit the changes.



    In other words, try something like this instead:



    dataGrid.ClickCell i, j

    dataGrid.Keys "^a[Del]New Value[Enter]" ' Clear the old value using Ctrl+A and Del, then enter a new value and press Enter



    Let me know how it works for you.