开发者

Key events on data grid in Flex3

开发者 https://www.devze.com 2023-02-25 07:18 出处:网络
I am working in Flex3. Here I have a datagrid which contains data. some columns are editable. when the user changes the column data web service is called. Here using function of focusOut, I am calling

I am working in Flex3. Here I have a datagrid which contains data. some columns are editable. when the user changes the column data web service is called. Here using function of focusOut, I am calling the web service by sending the data which comes from the datagrid through focusOut function. Now I want to call the web service when the user changes the column data and presses keyboard key 'Enter'. Here I can call function but the event does not carry datagrid's data to the function being called. Some one give 开发者_运维技巧me solution for this. Thank You.


use the enter event to send the data my requirement i used the following for UPDATE PROCESS( I THINK YOU ALSO EXPECTING FOR THE SAME)

CHECKOUT THE CODE..hope this will be useful....

<mx:DataGrid id="datagrid2" dataProvider="{cat}"  editable="true"  keyDown="gridkey(event)"   x="10" y="152"  visible="true" width="703">
            <mx:columns>
            <!--<mx:DataGridColumn dataField="catCode" headerText="CATEGORY CODE" editable="false"/>-->         
                    <mx:DataGridColumn dataField="catDesc" headerText="CATEGORY DESCRIPTION"  editable="true">
                    <mx:itemEditor >

                        <mx:Component>

                            <mx:TextInput  errorColor="#0294b3" errorString="Click Enter and Save"  restrict="A-Za-z0-9" maxChars="15"/>
                        </mx:Component>
                    </mx:itemEditor>
                    </mx:DataGridColumn>

                <mx:DataGridColumn dataField="updatedate" headerText="LAST UPDATE DATE" editable="false"/>

IN ACTION SCRIPT...USE THE FOLLOWING

public function gridkey(event:KeyboardEvent):void
            {

                if (event.keyCode == Keyboard.ENTER)
                {
                    var obj:Object = event.currentTarget.selectedItem;

                    for(var n:String in cat)
                    {

                        var items:CategoryVO = cat[n] as CategoryVO;
                        if(obj.catCode == items.catCode && obj.orgId == items.orgId)
                        {

                            items.catCode=obj.catCode;
                            items.catDesc=obj.catDesc;
                            items.updateby=obj.updateby;
                            items.alter = "Altered";  //use    private  var _alter:String; in flex VO class where remote class getters and settrs are used...//
                            //Alert.show(items.id.toString());
                            DeletedItems.push(items.catCode);
                        //  Alert.show(DeletedItems.toString());

                        }

                    }

                }


You could use the enter event on your itemEditor to send the data to your web service.

Here's a rough example:

<mx:itemEditor>
  <mx:Component>
    <mx:VBox>
      <mx:TextInput id="setCity" width="130" text="{data.City}" enter="outerDocument.callMyWebService(data)"/>
    </mx:VBox>
  </mx:Component>                 
</mx:itemEditor>


I think you should use Event itemEditEnd details can be found at

DataGrid Events

an useful example is

Creating an editable DataGrid control in Flex

hopes that helps

0

精彩评论

暂无评论...
验证码 换一张
取 消