4 Replies Latest reply on May 18, 2008 4:58 PM by smscentral

    Datagrid checkbox renderer

      Hi all,

      I have a datagrid with checkbox as item renderers and checkbox as header renderer in one of its columns.
      I created a custom datagrid column extending from datagrid column.

      The visible property of checkbox in a row is based on a condition.
      All works fine if there are only 7 rows in a datagrid,i get three rows with checkbox and the other without checkbox.
      but,if i have more than 7 rows(with vertical scrollbar) i see all the checkboxes visible which should not happen.


        • 1. Re: Datagrid checkbox renderer
          Sreenivas R Adobe Employee
          The itemRenderers of DG are recycled. They are not created for all data rows but only for the visible rows.

          Hence in the itemRenderer you need to override the setter of data or listData and set the visible flag to true AND false depending on the condition.

          This should fix the problem you are facing.
          • 2. Re: Datagrid checkbox renderer
            smscentral Level 1
            thanks for the reply sreenivas

            but i have already done that..
            here is my set data method

            override public function set data(value:Object):void{
            if(value != null){
            super.data = value;

            public function checkDelPermission(event:FlexEvent = null):void{
            var checkpermissioninstance:CheckPermission = new CheckPermission();
            checkpermissioninstance.permissions = [8];
            checkpermissioninstance.permBit = data.permission;
            var delpermission:ArrayCollection = checkpermissioninstance.getPermissions()
            this.visible = true;
            this.visible = false;
            MittoApp.logMessage("permission"+data.permission +" and visible=="+this.visible);

            the message is always printed with the correct values but the display is not.


            • 3. Re: Datagrid checkbox renderer
              Sreenivas R Adobe Employee
              Sorry. My bad. I didn't think through.

              The checkBoxes are becoming visible because that property is set to true by the DG.

              You have two options:

              1. Instead of using visible use enabled property.
              2. override updateDisplayList and set the visible property there.
              • 4. Re: Datagrid checkbox renderer
                smscentral Level 1
                thanku sreenivas.
                That works now