4 Replies Latest reply on Oct 3, 2006 7:11 PM by jpwrunyan

    DataGrid Sort Clears HeaderRenderer Checkbox

    JB_Sound Level 1
      I have a datagrid that I defined a checkbox as the headerrenderer for one of the columns. It took me a while to track this down, but it seems like a re-sort on one of the columns (other than the checkbox headerrenderer column) clears the state of the checkbox and resets it to chexkbox.selected=false.

      Is there any way to persist the checkbox selected property of a headerrenderer checkbox instance on re-sort.

      I played with disabling the default sort methods and creating my own sort functionality by only allowing a specific column to be sorted. That didn't solve my problem though.

      Thanks,

      JB
        • 1. Re: DataGrid Sort Clears HeaderRenderer Checkbox
          ntsiii Level 3
          I've not used a headerRenderer yet.

          Is it data-driven? If so, where does it get its data?.

          You might have to store the state in some external variable, and then re-set it in the renderers display code.

          Tracy
          • 2. Re: DataGrid Sort Clears HeaderRenderer Checkbox
            JB_Sound Level 1
            No, it's not data-driven, if you mean that it is bound to a data array of sorts. I set it manually based on some other conditions in the application. I'm storing the state in a variable and that is where I'm having a problem.

            It seems that upon resort the checkbox gets cleared no matter what the value of the external variable is.

            At the moment I had to resort back to not using it, as I haven't really been able to resolve this issue.

            JB
            • 3. Re: DataGrid Sort Clears HeaderRenderer Checkbox
              ntsiii Level 3
              Can you post a simple example? I'd like to poke around a bit.

              Tracy
              • 4. Re: DataGrid Sort Clears HeaderRenderer Checkbox
                jpwrunyan Level 1
                I did something similar with my DataGrid. The way I solved the problem was to make a global variable to hold the checkBox's checked value and then on the checkbox's click event ran a global function to handle the setting of the global var:

                <mx:DataGridColumn id="copyColumn" dataField="check"
                width="35">
                <mx:headerRenderer>
                <mx:Component>
                <mx:HBox horizontalAlign="center"
                verticalAlign="middle">
                <mx:CheckBox id="check"
                tabIndex="1" labelPlacement="top" selected=" {outerDocument.check_flg}"
                click=" outerDocument.checkAll(check.selected)" height="18" />
                </mx:HBox>
                </mx:Component>
                </mx:headerRenderer>
                </mx:DataGridColumn>

                note that the above code is contained in a component that extends mx:DataGrid
                I think you can get the jist...