spark Datagrid中的SelectItem方法? [英] SelectItem Method in spark Datagrid?

查看:198
本文介绍了spark Datagrid中的SelectItem方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这可以用于扩展 mx:Datagrid 其他答案

  override protected function selectItem(item:IListItemRenderer,
shiftKey:Boolean,ctrlKey:Boolean,
transition:Boolean = true):Boolean
{
//只运行选择代码如果一个复选框被击中,总是
//假装我们使用ctrl选择

if(item is CheckBox)
return super.selectItem(item,shiftKey,true,transition );
else // Avenir Cokaj 23/06/11:这使flex的自然选择
返回super.selectItem(item,shiftKey,ctrlKey,transition);

}

但是没有$ code> super。 s中的selectItem s:Datagrid 那么如何启用spark datagrid上的控制键?

解决方案

使用 selectionMode 属性。不需要更多的子类。在您的情况下,您需要将其设置为 multipleRows

  < s:DataGrid selectionMode =multipleRows/> 

其他值为:




  • none

  • 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


I am enabling multiple row selection with clicking checkbox Item renderer.

this works for extending mx:Datagrid (other answer)

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);

            }

But there is no super.selectItem in s:Datagrid So how to enable control key on spark datagrid?

解决方案

Use the selectionMode property. No more subclassing required. In your case, you would want to set it to multipleRows.

<s:DataGrid selectionMode="multipleRows" />

Other values are:

  • none
  • singleCell
  • singleRow (default)
  • multipleCells

I believe they are pretty self-explanatory.

Now if you wish the rows to be multi-selected with a single click (as if the control key were constantly pressed), you can do this by subclassing DataGrid like this:

public class MyDataGrid extends DataGrid {

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

}

We just intercept the event and set its ctrlKey property to always be true.

这篇关于spark Datagrid中的SelectItem方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆