1) implement an itemRenderer that displays a NumericStepper. You can use an in-line renderer, using the mx:Component tag, if the renderer is fairly simple. Set whatever properties you want in the initialization, assuming they are the same for all rows. Any dynamic characteristics mys be set by the dataProfider item. Find an example.
2) You can't "move" a ComboBox into a DataGrid. Implement a ComboBox itemRenderer, set any static properties on initialization, any dynamic properties in the set data() override. Example: http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectI D=767 Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeffrey Walker Sent: Thursday, March 13, 2008 2:22 PM To: [email protected] Subject: Re: [flexcoders] Problem with dataGrid and the itemRenderers for Numeric stepper and ComboBox Thanks for the response. But have you seen my problems before. If so, do you know I can fix it? 1. Numeric Stepper max being forced to 10 when moved to the datagrid. 2. ComboBox being blank when moved to the datagrid. Can you please help me with my existing code? Thanks On Thu, Mar 13, 2008 at 11:23 AM, Tracy Spratt <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: Using custom itemRenderers is easy if you are just rendering the data. But when you start to use them interactively, to modify the data it gets more complicated. Start here for some good info: http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.ht ml <http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.h tml> And some advice, do not start from scratch, but find an example close to what you want and modify it. There are *very* many itemRender examples available. Tracy ________________________________ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of jeffreyr6915 Sent: Thursday, March 13, 2008 1:11 PM To: [email protected] <mailto:[email protected]> Subject: [flexcoders] Problem with dataGrid and the itemRenderers for Numeric stepper and ComboBox I have a datagrid with an arrayCollection data provider. On a button click, I call a method to update the dataGrid. Some of the cells in the datagrid are supplied by comboBoxes and Numeric Steppers. The following are the problems that I am having: 1. When using the itemRenderer="mx.controls.NumericStepper", a numeric stepper is deployed into the datagrid as intended. But the maximum value becomes 10 and does not keep the maximum value of the original numeric stepper (i.e, any values of more than 10 will be changed to 10 when placed in the datagrid). How do I get the numeric stepper into the datagrid with the original maximum value? 2. When using the itemRenderer="mx.controls.ComboBox", an empty combobox is sent to the datagrid and not the comboBox populated with the original choices (with the user's choice the one selected). Note that if I use itemRenderer="mx.controls.TextInput", the user's choice populates the datagrid cell but it is only text and not the combobox. How can I get the original comboBox (with the user's choice selected) into the datagrid cell? <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FDFDFD, #FDFCFC]"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.List; import mx.controls.CheckBox; import mx.controls.ComboBox; [Bindable] private var myArray1:Array = new Array("a", "b", "c"); [Bindable] private var myArray2:Array = new Array("a", "b", "c"); [Bindable] private var myArray3:Array = new Array("a", "b", "c"); [Bindable] private var dataGridProvider:ArrayCollection = new ArrayCollection(); [Bindable] private var selectCheckBox:CheckBox = new CheckBox(); private var cb:ComboBox = new ComboBox(); private function updateTable():void { //Add the new data into the table (into the next row of the table) dataGridProvider.addItem({col1:selectCheckBox, col2:cb1.selectedLabel,col3: input1.text, col4:cb2.selectedLabel, col5:ns1.value ,col6:cb3.selectedLabel, col7:ns2.value}); //Update the table's dataprovider with the updated task row table.dataProvider = dataGridProvider; //Clear the data from the new task input form cb1.selectedIndex = -1; input1.text = null; cb2.selectedIndex = -1; ns1.value = 0; cb2.selectedIndex = -1; ns2.value = 0; } private function removeTaskRecord():void { //Check if the checkbox for the task is selected //((CheckBox)(((Array)(dataGridProvider.getItemIndex(scrumTable.selected Index)))[0])).selected if(table.selectedIndex>=0)//selectCheckBox.selected)//if(datagrid selected index is greater than or equal to 0) { //Remove the task record from the Data Grid data provider dataGridProvider.removeItemAt(table.selectedIndex); } } ]]> </mx:Script> <mx:Panel width="1027" height="382" layout="absolute" borderColor="#0C2B73" left="10" bottom="10"> <mx:DataGrid x="10" y="10" width="984" height="295" wordWrap="true" id="table" dataProvider="{dataGridProvider}" draggableColumns="false" variableRowHeight="true"> <mx:columns> <mx:DataGridColumn headerText="col1" dataField="col1" editable="true" itemRenderer="mx.controls.CheckBox" width="50" textAlign="center"/> <mx:DataGridColumn headerText="col2" dataField="col2" editable="true" itemRenderer="mx.controls.TextInput"/> <mx:DataGridColumn headerText="col3" dataField="col3" editable="true" itemRenderer="mx.controls.TextInput"/> <mx:DataGridColumn headerText="col4" dataField="col4" editable="true" itemRenderer="mx.controls.TextInput"/> <mx:DataGridColumn headerText="col5" dataField="col5" editable="true" itemRenderer="mx.controls.NumericStepper"/> <mx:DataGridColumn headerText="col6" dataField="col6" editable="true" itemRenderer="mx.controls.TextInput"/> <mx:DataGridColumn headerText="col7" dataField="col7" editable="true" itemRenderer="mx.controls.NumericStepper"/> </mx:columns> </mx:DataGrid> <mx:Button x="921" y="313" label="Remove" id="removeBtn" enabled="true" click="removeTaskRecord()"/> </mx:Panel> <mx:Panel width="520" height="308" layout="absolute" left="10" top="33" borderColor="#0C2B73"> <mx:ComboBox x="10" y="40" id="cb1" dataProvider="{myArray1}" width="169" selectedIndex="-1"></mx:ComboBox> <mx:TextInput x="202" y="40" width="255" id="input1"/> <mx:ComboBox x="10" y="107" dataProvider="{myArray2}" selectedIndex="-1" id="cb2"></mx:ComboBox> <mx:ComboBox x="202" y="107" dataProvider="{myArray3}" selectedIndex="-1" id="cb3"></mx:ComboBox> <mx:NumericStepper x="10" y="179" maximum="25" id="ns1"/> <mx:NumericStepper x="202" y="179" maximum="25" id="ns2"/> <mx:Button x="392" y="218" label="Submit" id="sbBtn" click="updateTable()"/> </mx:Panel> </mx:Application>

