-->

的SelectItem方法火花Datagrid的?(SelectItem Method in spa

2019-10-16 21:14发布

我能够与点击复选框项渲染多行选择。

这适用于扩展mx:Datagrid ( 其他答案 )

override protected function selectItem(item:IListItemRenderer,
                                                   shiftKey:Boolean, ctrlKey:Boolean,
                                                   transition:Boolean = true):Boolean
            {
                // only run selection code if a checkbox was hit and always
                // pretend we're using ctrl selection

                if (item is CheckBox)
                    return super.selectItem(item, shiftKey, true, transition);
                else //Avenir Cokaj 23/06/11: this enables the flex's natural selection
                    return super.selectItem(item, shiftKey, ctrlKey, transition);

            }

但没有super.selectItems:Datagrid那么如何启用火花DataGrid控件的关键?

Answer 1:

使用的SelectionMode属性。 无需更多的子类。 在你的情况,你会希望将其设置为multipleRows

<s:DataGrid selectionMode="multipleRows" />

其他值:

  • 没有
  • singleCell
  • singleRow(默认)
  • multipleCells

我相信他们是不言自明。

现在,如果你想行要多选择一个单一的点击(如同控制键被持续压),你可以通过继承DataGrid中这样做:

public class MyDataGrid extends DataGrid {

    override protected function grid_mouseDownHandler(event:GridEvent):void {
        event.ctrlKey = true;
        super.grid_mouseDownHandler(event);
    }

}

我们刚刚截获该事件并设置其ctrlKey属性始终是true



文章来源: SelectItem Method in spark Datagrid?