Flex DataGrid 伪合并单元格思路及代码
程序员文章站
2022-03-21 23:33:27
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:mxdatagriditemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%"
autodrawbackground="false"
creationcomplete="mxitemrenderer1_creationcompletehandler(event)"
>
<s:layout>
<s:verticallayout verticalalign="middle" horizontalalign="center"/>
</s:layout>
<fx:script>
<![cdata[
import mx.collections.arraycollection;
import mx.controls.text;
import mx.events.flexevent;
protected function mxitemrenderer1_creationcompletehandler(event:flexevent):void
{
var txt1:string = lbl.text.split(",")[0];
var txt2:string = lbl.text.split(",")[1];
lbl1.text = txt1;
lbl2.text = txt2;
}
]]>
</fx:script>
<fx:declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:declarations>
<s:label id="lbl" text="{datagridlistdata.label}" visible="false" height="0"/>
<s:vgroup id="vp" width="100%" height="100%" gap="2" >
<s:label id="lbl1" color="0x000000" textalign="center" verticalalign="middle" width="100%"/>
<mx:hrule width="100%" chromecolor="0x999999" alpha="0.3"/>
<s:label id="lbl2" color="0x000000" textalign="center" verticalalign="middle" width="100%"/>
</s:vgroup>
</s:mxdatagriditemrenderer>
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<s:mxdatagriditemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%"
autodrawbackground="false"
creationcomplete="mxitemrenderer1_creationcompletehandler(event)"
>
<s:layout>
<s:verticallayout verticalalign="middle" horizontalalign="center"/>
</s:layout>
<fx:script>
<![cdata[
import mx.collections.arraycollection;
import mx.controls.text;
import mx.events.flexevent;
protected function mxitemrenderer1_creationcompletehandler(event:flexevent):void
{
var txt1:string = lbl.text.split(",")[0];
var txt2:string = lbl.text.split(",")[1];
lbl1.text = txt1;
lbl2.text = txt2;
}
]]>
</fx:script>
<fx:declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:declarations>
<s:label id="lbl" text="{datagridlistdata.label}" visible="false" height="0"/>
<s:vgroup id="vp" width="100%" height="100%" gap="2" >
<s:label id="lbl1" color="0x000000" textalign="center" verticalalign="middle" width="100%"/>
<mx:hrule width="100%" chromecolor="0x999999" alpha="0.3"/>
<s:label id="lbl2" color="0x000000" textalign="center" verticalalign="middle" width="100%"/>
</s:vgroup>
</s:mxdatagriditemrenderer>
上一篇: XSL简明教程