熟悉excel的人應該都知道**中可以將比如標題行/列鎖定,使其不滾動,從而便於瀏覽。flex的datagrid控制項也可以實現這樣的效果。接下來的例子演示了flex中如何鎖定橫向滾動datagrid控制項的列。demo中name列被鎖定
xml version="1.0" encoding="utf-8"
?>
<
xmlns:mx
=""layout
="vertical"
verticalalign
="middle"
backgroundcolor
="white"
>
<
mx:datagrid
id="datagrid"
lockedcolumncount
="1"
horizontalscrollpolicy
="on"
width
="300"
>
<
mx:columns
>
<
mx:datagridcolumn
datafield
="@name"
headertext
="name:"
/>
<
mx:datagridcolumn
datafield
="@cola"
headertext
="column a:"
/>
<
mx:datagridcolumn
datafield
="@colb"
headertext
="column b:"
/>
<
mx:datagridcolumn
datafield
="@colc"
headertext
="column c:"
/>
mx:columns
>
<
mx:dataprovider
>
<
mx:xmllist
>
<
item
name
="user 1"
cola
="1.a"
colb
="1.b"
colc
="1.c"
/>
<
item
name
="user 2"
cola
="2.a"
colb
="2.b"
colc
="2.c"
/>
<
item
name
="user 3"
cola
="3.a"
colb
="3.b"
colc
="3.c"
/>
<
item
name
="user 4"
cola
="4.a"
colb
="4.b"
colc
="4.c"
/>
<
item
name
="user 5"
cola
="5.a"
colb
="5.b"
colc
="5.c"
/>
<
item
name
="user 6"
cola
="6.a"
colb
="6.b"
colc
="6.c"
/>
<
item
name
="user 7"
cola
="7.a"
colb
="7.b"
colc
="7.c"
/>
<
item
name
="user 8"
cola
="8.a"
colb
="8.b"
colc
="8.c"
/>
mx:xmllist
>
mx:dataprovider
>
mx:datagrid
>
>
其中最重要的屬性就是lockedcolumncount ,控制鎖定列的數
flex中獲取datagrid選中行的列值
var v object datagrid.editeditemposition var colindex number v.columnindex var rowindex number v.rowindex var colatagridcolumn datagrid.columns colind...
Flex 動態調整DataGrid列的顯示
當datagrid需要呈現n多列的時候,要麼列顯示不全都擠在一起,要麼就出現橫向的滾動條。這些感覺都不和諧。那麼實現的方案有幾種 1 給每列加個id,然後用別的控制項 例如combobox 來控制每列顯示,來開關列的顯示和隱藏,類似js那樣的做法,但那樣 量太大,寫通用的方法也太麻煩了。2 基於上面...
FLEX 獲取DataGrid行號和列好
一 獲取行號 var findex number math.floor dg.contentmousey dg.rowheight 1 dg.verticalscrollposition 是滑鼠所在的local座標系相對於datagrid的高度 是datagrid的行高,math.floor作用是截...