5 Replies Latest reply on Nov 21, 2010 1:30 AM by drkstr_1

    HSlider within AdvancedDataGrid

    sd_brown

      I have been trying to implement a HSlider within an AdvancedDataGrid,

       

      Can anyone point me in the right way, what I have managed, which dosn't work is as follows...

       

      http://sbrown.myip.org/files/dghs/advDataGridSlider.html (Source Code View Enabled)

       

      - Stephen Brown

        • 1. Re: HSlider within AdvancedDataGrid
          drkstr_1 Level 4

          It would help if you told us what you were trying to do...

           

          **EDIT**

           

          Never mind, I see the problem. You are not updating the underlying data when the slider changes. You need to set this.data.Actual to the new sliderValue when it changes.

          • 2. Re: HSlider within AdvancedDataGrid
            sd_brown Level 1

            I require an AdvancedDataGrid to show an ArrayCollection that is grouped by one of the arrayCollections fields. The arrayCollection will have a field that represents an amount of money which can be chosen by either entering the figure or by using a HSlider as an itemRenderer. The Summary rows will not need this itemRenderer but the item rows will. When changes are made they must update the arrayCollection immediatly they are made and reamin set to what value that was typed or slid to when the row is scrolled off and back on the datagrid and when the row is closed and re-opened by clicking on the group.

             

            I hope this description is sufficient,

             

            Thanks,

             

            Stephen

            • 3. Re: HSlider within AdvancedDataGrid
              drkstr_1 Level 4

              I edited my first reply shortly after I made it.

              • 4. Re: HSlider within AdvancedDataGrid
                Matt Le Fevre Level 4

                my head started going round in circles when i tried to read what you wrote but i think i know what you're talking about.

                 

                Essentially, when you change the slider value, close that branch, then re-open it, changes havn't been saved.... i think?

                 

                if so, here's a quick and easy fix:

                 

                in advDataGridSlider.mxml, add this function:

                 

                public function updateShizz(newValue:Number):void
                {
                     advDataGrid.selectedItem.Actual = newValue;
                     trace(newValue);
                }

                 

                in slider.mxml, add this function

                 

                private function doThis():void
                {
                     parentApplication.updateShizz(hSlider.value);
                }

                 

                and alter the mxml HSlider component to have this in it

                 

                <s:HSlider id="hSlider" width="80%" top="4" minimum="0" maximum="6000"
                                   value="{sliderValue}"
                                   change="hSlider_changeHandler(event)" changeEnd="doThis()"/>

                 

                 

                 

                or you can keep all the processing in your item renderer, a parent call is merely my preference.

                • 5. Re: HSlider within AdvancedDataGrid
                  drkstr_1 Level 4

                  Yup, you need to save the changes to the data or they could get reset when the display updates. You can read more about it here:

                   

                  http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html

                   

                   

                  For your problem, simply updating the data renderer would suffice. Objects are passed by reference, so you would be updating the same Object that is sitting in your dataProvider.

                   

                  
                  protected function hSlider_changeHandler(event:Event):void
                  {
                       sliderValue = hSlider.value;
                       this.data.Actual = sliderValue;
                       dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
                  }
                  
                  

                   

                  If you want to wait for a data commit (the user hit's enter, or other types of committing interactions), then you need to listen to the itemEditEnd event on your DataGrid, and update the data then. This method doesn't really make sense with sliders though. I would just go with the code above.