You could manually update the TextInput fields' widths by capturing the
columnStretch event. The initial binding in this example was used to
match the textinputs' widths when the app first fires up -- these could
also be set on creationComplete to avoid this binding:
 
<mx:DataGrid columnStretch="onColumnStretch(event)">
    <mx:columns>
      <mx:DataGridColumn id="dgc1"/>
      <mx:DataGridColumn id="dgc2"/>
    </mx:columns>
  </mx:DataGrid>
  <mx:HBox id="hb1" horizontalGap="1">
    <mx:TextInput width="{dgc1.width}"/>
    <mx:TextInput width="{dgc2.width}"/>
  </mx:HBox>
 
------
 
//Stretch handler
 
private function onColumnStretch(event:DataGridEvent):void
      {
        for (var i:int = 0; i < DataGrid(event.target).columnCount; i++)
        {
          hb1.getChildAt(i).width =
DataGrid(event.target).columns[i].width;
        }
      }
 
HTH,
Ryan
 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of biosmonkey
Sent: Wednesday, October 29, 2008 8:54 AM
To: [email protected]
Subject: [flexcoders] Binding textinput width to datagrid column width?



I must be doing something dumb, but I can't understand why this isn't
working.

I have a datagrid with say, 2 columns. Under the datagrid, I have two
text input controls next to each other in an hbox.

I want the text input controls to match the width of the datagrid
columns directly above them. This means when the datagrid is drawn and
the column widths determined, the textinput controls should resize
themselves to match. This also should occur if the user resizes the
columns manually.

So, I assigned IDs to the datagridcolumn objects, and tried to bind
the width of the text input controls to them.

So first I tried
<mx:TextInput width="{colName.width}"....>

and this didn't work.

So then I tried a bindproperty:

BindingUtils.bindProperty(txtiName,"width",colName ,"width");

and this didn't work either.

So then I used a bindsetter just for the purpose of setting a
breakpoint in the function to see if it was firing. It fires only on
init, and not when the columns are resized.

What am I doing wrong?



 


This message is private and confidential. If you have received it in error, 
please notify the sender and remove it from your system.

Reply via email to