0

what i am trying to achieve is to have data populate a datagrid from a query, this part works fine. but once the data has been populated i want to add an additional row which the user will be able to type into. so for example the grid will have 5 pre populated rows and then the 6th row will be empty cells which the user can edit. the final column of this row will either be a button or an image with the click property set. this will be used to run an update query to update the dataprovider of the datagrid.

kris
  • 90
  • 1
  • 1
  • 12

2 Answers2

1

This is pretty easy. Just add a new object in your List that is bound to the datagrid. For the final column you will need an item renderer.

Ex:

dataGrid.dataProvider = someList;

//later when it is populated
someList.addItem(new Item());

After this you can set the focus to the desired column and the last row to show its input time.

You can also remove the last added item from the list to simulate a cancel action.

huber.duber
  • 762
  • 2
  • 7
  • 31
1

You will also need to set the 'editable' property of the grid to true. Set the selectionMode property to 'singleRow' Each column also has an individual 'editable' property so you can limit users to only changing certain properties.

As long as the data is simple text the default item editor (which is a textInput) will work fine. If you use an advancedDataGrid you can also include things like checkBoxes for Boolean data.

schwack
  • 88
  • 6
  • all worked except for selection mode, this is a spark property and wont work for mxml. I still havent been able to make just one row editable – kris Jun 03 '14 at 09:51
  • editors are based on the columns, not the rows. What you CAN do howeever. is set a listener on the 'itemEditBegin' property, check the value of the row and cancel the default for all rows except the last. – schwack Jun 10 '14 at 01:55
  • btw - if your document is using the xmlns:fx="http://ns.adobe.com/mxml/2009" namespace you can include any spark components you like by including the spark namespace: xmlns:s="library://ns.adobe.com/flex/spark" – schwack Jun 10 '14 at 02:04