Re: [flexcoders] itemRenderer ComboBox

2009-01-03 Thread Manish Jethani
On Sat, Jan 3, 2009 at 1:15 AM, Mike Oliver moli...@corenttech.com wrote:

 Perhaps its because it is an itemEditor, but just tried it and value in the
 editorDataField saves the label string to the Grid, not the 'data' element.

Well, the value property is a little strange indeed. Not to mention
it's also deprecated. Here's what I suggest:

  /* in your item editor */
  public function get myCustomProperty():Object
  {
var item:Object = selectedItem;
if (item == null)
  return null;

return item.data;
  }

  DataGridColumn editorDataField=myCustomProperty ... /

Manish

-- 
http://manishjethani.com


Re: [flexcoders] itemRenderer ComboBox

2009-01-03 Thread Mike Oliver

Yes that's what it takes, thanks!  

I used an itemRenderer to set the display to the label from the lookup
source for the data that was stored.  


Manish Jethani wrote:
 
 Here's what I suggest:
 
   /* in your item editor */
   public function get myCustomProperty():Object
   {
 var item:Object = selectedItem;
 if (item == null)
   return null;
 
 return item.data;
   }
 
   DataGridColumn editorDataField=myCustomProperty ... /
 
 Manish
 
 -- 
 http://manishjethani.com
 
 

-- 
View this message in context: 
http://www.nabble.com/itemRenderer-ComboBox-tp21243094p21266561.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] itemRenderer ComboBox

2009-01-02 Thread Mike Oliver

Ok, so the itemEditor = ComboBox with the above Override and here it is as it
stands and works (up to a point).

mx:DataGridColumn headerText=Reason Stopped
dataField=reason_med_stopped_oidCol
editorDataField=selectedItem
mx:itemEditor
mx:Component
mx:ComboBox editable=true labelField=label 
mx:ArrayCollection
 mx:Object label=Patient Died 
data=130/
 mx:Object label=Maximum dosage 
data=131/
 mx:Object label=Consulting Decision 
data=132/
  /mx:ArrayCollection
mx:Script
![CDATA[
import 
mx.collections.IViewCursor;

override public function set 
data(value:Object):void
   {
  super.data = value;

  var 
listCursor:IViewCursor = collection.createCursor();
  do
  {
 if 
(data.reason_med_stopped_oidCol ==
listCursor.current.data)
 {
 selectedItem = 
listCursor.current;
 break;
}
  }
  while 
(listCursor.moveNext());
}
]]
/mx:Script
/mx:ComboBox

/mx:Component
/mx:itemEditor
/mx:DataGridColumn

Now this works perfectly now when I click in the Cell the ComboBox opens
with the selectedItem and when I select an option and exit the Cell the
DataGridEvent.ITEM_EDIT_END fires and I extract the data value to insert
into the parameters with

parameters[dsFieldName.substr(0,dsFieldName.length-3)] =
e.currentTarget.itemEditorInstance.selectedItem.data;

and that saves to the database, all great...however, the 

editorDataField=selectedItem puts [object Object] into the Grid instead
of the data element.  

I tried editorDataField=selectedItem.data but that fails.  I tried value
and text but it saves the Label.

So what do I put in the editorDataField to save the 'data' to the Grid
instead of the object string or the label?


-- 
View this message in context: 
http://www.nabble.com/itemRenderer-ComboBox-tp21243094p21255448.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] itemRenderer ComboBox

2009-01-02 Thread Manish Jethani
On Sat, Jan 3, 2009 at 12:16 AM, Mike Oliver moli...@corenttech.com wrote:

[snip]
 and that saves to the database, all great...however, the

 editorDataField=selectedItem puts [object Object] into the Grid instead
 of the data element.

 I tried editorDataField=selectedItem.data but that fails.  I tried value
 and text but it saves the Label.

 So what do I put in the editorDataField to save the 'data' to the Grid
 instead of the object string or the label?

Strange. Setting editorDataField to 'value' should work if you have a
field called 'data' in the selected item and that's the value you're
looking for.

?xml version=1.0?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  xmlns=* 

  mx:TextInput text={cb.value} /

  mx:ComboBox labelField=l id=cb
mx:dataProvider
  mx:Object l=foo data=1 /
  mx:Object l=bar data=2 /
/mx:dataProvider
  /mx:ComboBox

/mx:Application

Manish

-- 
http://manishjethani.com


Re: [flexcoders] itemRenderer ComboBox

2009-01-02 Thread Mike Oliver

Perhaps its because it is an itemEditor, but just tried it and value in the
editorDataField saves the label string to the Grid, not the 'data' element.

Ollie


Manish Jethani wrote:
 
 On Sat, Jan 3, 2009 at 12:16 AM, Mike Oliver moli...@corenttech.com
 wrote:
 
 [snip]
 and that saves to the database, all great...however, the

 editorDataField=selectedItem puts [object Object] into the Grid
 instead
 of the data element.

 I tried editorDataField=selectedItem.data but that fails.  I tried
 value
 and text but it saves the Label.

 So what do I put in the editorDataField to save the 'data' to the Grid
 instead of the object string or the label?
 
 Strange. Setting editorDataField to 'value' should work if you have a
 field called 'data' in the selected item and that's the value you're
 looking for.
 
 ?xml version=1.0?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
   xmlns=* 
 
   mx:TextInput text={cb.value} /
 
   mx:ComboBox labelField=l id=cb
 mx:dataProvider
   mx:Object l=foo data=1 /
   mx:Object l=bar data=2 /
 /mx:dataProvider
   /mx:ComboBox
 
 /mx:Application
 
 Manish
 
 -- 
 http://manishjethani.com
 
 

-- 
View this message in context: 
http://www.nabble.com/itemRenderer-ComboBox-tp21243094p21256481.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] itemRenderer ComboBox

2009-01-01 Thread Mike Oliver

it looks to me like it is better to use a label function to render the
display value and leave the combo box for itemEditor.

That still leaves the question on how the ComboBox will display the Option
Label when in edit mode.


-- 
View this message in context: 
http://www.nabble.com/itemRenderer-ComboBox-tp21243094p21245495.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] itemRenderer ComboBox

2009-01-01 Thread Manish Jethani
On Fri, Jan 2, 2009 at 3:59 AM, Mike Oliver moli...@corenttech.com wrote:

 it looks to me like it is better to use a label function to render the
 display value and leave the combo box for itemEditor.

 That still leaves the question on how the ComboBox will display the Option
 Label when in edit mode.

The ComboBox won't select the item based on the value of the 'text'
property, so you'll have to do the selection for it, by overriding the
data setter.

  override public function set data(value:Object):void
{
  super.data = value;

  var listCursor:IViewCursor = collection.createCursor();
  do
  {
if (data.med_route_oidCol == listCursor.current.text)
{
  selectedItem = listCursor.current;
  break;
}
  }
  while (listCursor.moveNext());
  }

Manish


Re: [flexcoders] itemRenderer ComboBox

2009-01-01 Thread Mike Oliver

Thanks, so this script would go within the 

mx:ComboBox...

/mx:ComboBox

Right?


Manish Jethani wrote:
 
 On Fri, Jan 2, 2009 at 3:59 AM, Mike Oliver moli...@corenttech.com
 wrote:
 
 it looks to me like it is better to use a label function to render the
 display value and leave the combo box for itemEditor.

 That still leaves the question on how the ComboBox will display the
 Option
 Label when in edit mode.
 
 The ComboBox won't select the item based on the value of the 'text'
 property, so you'll have to do the selection for it, by overriding the
 data setter.
 
   override public function set data(value:Object):void
 {
   super.data = value;
 
   var listCursor:IViewCursor = collection.createCursor();
   do
   {
 if (data.med_route_oidCol == listCursor.current.text)
 {
   selectedItem = listCursor.current;
   break;
 }
   }
   while (listCursor.moveNext());
   }
 
 Manish
 
 

-- 
View this message in context: 
http://www.nabble.com/itemRenderer-ComboBox-tp21243094p21246607.html
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] itemRenderer ComboBox

2009-01-01 Thread Manish Jethani
On Fri, Jan 2, 2009 at 6:09 AM, Mike Oliver moli...@corenttech.com wrote:

 Thanks, so this script would go within the

 mx:ComboBox...

 /mx:ComboBox

 Right?

Yes.

Manish

-- 
http://manishjethani.com