Datagrid在我的datagrid中选择错误的自定义单元格 [英] Datagrid selects the wrong custom cell in my datagrid

查看:200
本文介绍了Datagrid在我的datagrid中选择错误的自定义单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一周以来一直在努力解决问题,但是我仍然无法按预期方式工作。我有一个DataGrid,它具有一个CheckBox和一个Label作为itemRenderer的HBox(参见下面的代码)。当我点击单元格,弹出标准itemEditor,并允许您输入标签的内容。这是标准行为。我可以正常工作,除了2个问题:

I am working on a problem since a week soon, but I still couldn't make it work as expected. I have a DataGrid which has HBox with a CheckBox an a Label as itemRenderer (see Code below). When I tap in to the Cell the standard itemEditor pops up and lets you enter the content of the label. Thats the standard behavior. I works fine except for 2 problems:


  1. 如果我输入多个文本,水平滚轮弹出,单元格充满了滚动条。正如你所看到的,我试图将horizo​​ntalScrollPolicy设置为off,但是这根本不起作用...我试图为所有不同的元素执行此操作,但是失败仍然存在。

  1. If I enter to much text, the horizontal srollbar pops up, and the cell is filled with that scrollbar. As you see I tried to set the horizontalScrollPolicy to off, but that doesnt work at all... I tried to do that for all the different elements, but the failure is still existent.

当我填写多行时,还有一个错误发生。如果我点击一行,datagrid选择该行下面的那个。只有当一行已经被选中时才是这样。如果我在数据网格外点击,然后点击右排itemEditor将显示的任何行...在设置数据方法中有什么现在可以吗?

When I have filled more than one row, there is an other mistake happening. If I tap on a row, the datagrid selects the one below that row. That's only if one line is already selected. If I tap outside the datagrid and then, tap at any row the itemEditor of the right row will show up... Is there anything now wright in the setup of my set data method?

__

package components
{
 import mx.containers.HBox;
 import mx.controls.CheckBox;
 import mx.controls.Label;

 public class ChoiceRenderer extends HBox
 {

  private var correctAnswer:CheckBox;
  private var choiceLabel:Label;

  public function ChoiceRenderer()
  {
   super();
   paint();
  }

  private function paint():void{
   percentHeight = 100;
   percentWidth = 100;
   setStyle("horizontalScrollPolicy", "off");
   super.setStyle("horizontalScrollPolicy", "off");

   correctAnswer = new CheckBox;
   correctAnswer.setStyle("horizontalScrollPolicy", "off");  
   addChild(correctAnswer);

   choiceLabel = new Label;
   choiceLabel.setStyle("horizontalScrollPolicy", "off");   
   addChild(choiceLabel);  


  }

     override public function set data(xmldata:Object):void{
      if(xmldata.name() == "BackSide"){
       var xmlText:Object = xmldata.TextElements.TextElement.(@position == position)[0];
       super.data = xmlText;
       choiceLabel.text = xmlText.toString();
       correctAnswer.selected = xmlText.@correct_answer;

      }               
 }
}

提前!
Markus

Thanks in advance! Markus

推荐答案


  • 为了避免滚动条,你必须让datagrid有变量高度

  • 
    
    <mx:DataGrid id="dg"
     dataProvider="{dp}"
     variableRowHeight="true" 
     creationComplete="dg.height=dg.measureHeightOfItems(0,dp.length)+dg.headerHeight+2"/>
    

    这篇关于Datagrid在我的datagrid中选择错误的自定义单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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