Flex 행 번호 생성
9793 단어 Flex
public function indexNumLabelFun(value:Object, dataGrid:Object):String { var arr:Array = (PageDataGrid.dataProvider as ArrayCollection).toArray(); var indexNum: int = (arr.indexOf(value) + 1); Alert.show(indexNum.toString(), "prompt"); data.abc = indexNum.toString(); return indexNum.toString();}
----------------------------------------------------------------------------------------------------------------------------
public function genrowno(ob:Object):String { return String(PageDataGrid.dataProvider.getItemIndex(ob) + 1); }
--------------------------------------------------------------------------------------------------------------------------------
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center">
<mx:Script>
<![CDATA[
import mx.controls.AdvancedDataGrid;
import mx.controls.Alert;
import mx.events.FlexEvent;
override public function set data(value:Object):void
{
if(value != null)
{
super.data = value;
LbSequence.text=((this.owner as AdvancedDataGrid).dataProvider.getItemIndex(value)+1).toString();
}
}
]]>
</mx:Script>
<mx:Label id="LbSequence" />
</mx:HBox>
<mx:AdvancedDataGridColumn headerText=" " itemRenderer=" cn.edu.whu.liesmars.renderer.SequenceItemRenderer"/>
-------------------------------------------------------------------------------------------------------------------------------------
private function formatIndexNumber(item:Object, colum:Object):String
{
return indexNumLabelFun(item, colum.mx_internal::owner);
}
public static function indexNumLabelFun(value:Object, dataGrid:Object):String
{
var arr: Array = dataGrid.dataProvider.source;
var indexNum: int = (arr.indexOf(value) + 1);
return indexNum.toString();
}
<mx:DataGridColumn headerText=" " labelFunction="SimpleUtil.formatIndexNumber" width="50"/>
------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true">
<fx:Script>
<![CDATA[
override public function set rowIndex(value:int):void
{
lblData.label = (value + 1).toString();
}
]]>
</fx:Script>
<s:Button id="lblData" width="100%" height="100%"/>
</s:GridItemRenderer>
<?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"
applicationComplete="applicationCompleteHandler(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.FlexEvent;
private var ar:ArrayCollection;
private function applicationCompleteHandler(event:FlexEvent):void
{
ar = new ArrayCollection();
var user:User = null;
for(var i:int = 1; i <= 100; i++) {
user = new User();
user.id = i;
user.username = "abc" + i;
user.password = "efg" + i;
ar.addItem(user);
}
this.dg.dataProvider = ar;
}
]]>
</fx:Script>
<s:HGroup width="100%">
<s:DataGrid id="dg" editable="true" rowHeight="25" width="100%" height="375" alternatingRowColors="[#FFFFFF,#EEEEEE]">
<s:columns>
<s:ArrayList>
<s:GridColumn headerText=" " width="40" itemRenderer="CustomItemRenderer" editable="false"/>
<s:GridColumn dataField="id" headerText="ID"/>
<s:GridColumn dataField="username" headerText="USERNAME" />
<s:GridColumn dataField="password" headerText="PASSWORD"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:HGroup>
</s:Application>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
⭐️ Flex & OpacityThe flex CSS shorthand property sets how a flex item will grow or shrink to fit the space available in its flex containe...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.