flex4 关于dataGrid怎么删除选定的行? 30
我这里已经做好一个小东西,可以执行增加和删除功能,问题是增加和删除都在最后一行。请问,我的这个代码要怎么修改,才能实现增加到选定的行,或者删除选定的行?代码如下:<?xm...
我这里已经做好一个小东西,可以执行增加和删除功能,问题是增加和删除都在最后一行。
请问,我的这个代码要怎么修改,才能实现增加到选定的行,或者删除选定的行?
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
var display:ArrayCollection=new ArrayCollection([
{col1: "1", col2: "3", col3:"5",col4:"7"},
{col1: "2", col2: "4", col3:"6",col4:"8"},
{col1: "2", col2: "4", col3:"6",col4:"8"}
]);
[Bindable]
var arra:ArrayCollection = new ArrayCollection([
{label:"请选择"},{label:"China"},{label:"America"},{label:"Janpan"}
])
protected function update(event:MouseEvent):void
{
var obj:Object = {col1:input01.text,col2:input02.text,col3:input03.text,col4:input04.text}
trace(obj.A)
display.addItem(obj);
}
protected function deleteRecord(event:MouseEvent):void
{
display.removeItemAt(display.length-1)
}
]]>
</fx:Script>
<s:Panel x="66" y="38" width="687" height="355">
<mx:DataGrid x="55" y="29" dataProvider="{display}" id="dataGrid" height="118">
<mx:columns>
<mx:DataGridColumn headerText="A" dataField="col1"/>
<mx:DataGridColumn headerText="B" dataField="col2"/>
<mx:DataGridColumn headerText="C" dataField="col3"/>
<mx:DataGridColumn headerText="D" dataField="col4"/>
</mx:columns>
</mx:DataGrid>
<s:Label x="87" y="185" text="动态更改: " width="70" height="19"/>
<s:TextInput x="217" y="180" id="input01" width="32"/>
<s:TextInput x="265" y="180" id="input02" width="29"/>
<s:TextInput x="175" y="180" id="input03" width="29"/>
<s:TextInput x="308" y="180" id="input04" width="31"/>
<s:Button x="382" y="179" label="确定" id="button01" click="update(event)"/>
<s:Button x="382" y="233" label="删除" id="button02" click="deleteRecord(event)"/>
</s:Panel>
</s:Application> 展开
请问,我的这个代码要怎么修改,才能实现增加到选定的行,或者删除选定的行?
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
var display:ArrayCollection=new ArrayCollection([
{col1: "1", col2: "3", col3:"5",col4:"7"},
{col1: "2", col2: "4", col3:"6",col4:"8"},
{col1: "2", col2: "4", col3:"6",col4:"8"}
]);
[Bindable]
var arra:ArrayCollection = new ArrayCollection([
{label:"请选择"},{label:"China"},{label:"America"},{label:"Janpan"}
])
protected function update(event:MouseEvent):void
{
var obj:Object = {col1:input01.text,col2:input02.text,col3:input03.text,col4:input04.text}
trace(obj.A)
display.addItem(obj);
}
protected function deleteRecord(event:MouseEvent):void
{
display.removeItemAt(display.length-1)
}
]]>
</fx:Script>
<s:Panel x="66" y="38" width="687" height="355">
<mx:DataGrid x="55" y="29" dataProvider="{display}" id="dataGrid" height="118">
<mx:columns>
<mx:DataGridColumn headerText="A" dataField="col1"/>
<mx:DataGridColumn headerText="B" dataField="col2"/>
<mx:DataGridColumn headerText="C" dataField="col3"/>
<mx:DataGridColumn headerText="D" dataField="col4"/>
</mx:columns>
</mx:DataGrid>
<s:Label x="87" y="185" text="动态更改: " width="70" height="19"/>
<s:TextInput x="217" y="180" id="input01" width="32"/>
<s:TextInput x="265" y="180" id="input02" width="29"/>
<s:TextInput x="175" y="180" id="input03" width="29"/>
<s:TextInput x="308" y="180" id="input04" width="31"/>
<s:Button x="382" y="179" label="确定" id="button01" click="update(event)"/>
<s:Button x="382" y="233" label="删除" id="button02" click="deleteRecord(event)"/>
</s:Panel>
</s:Application> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询