4 Replies Latest reply on Jan 28, 2011 4:53 PM by Michael L Hale

    Is DataGrid control the best choice...

    Michael L Hale Level 5

      I only have a little experience creating panel and so far have only used simple controls like Button, TextInput, etc.

       

      I have a project for Photoshop where I need to create a panel that looks similar to the Layer Comps. It also need to have similar UI functionality. That is to say when the user clicks on the first column in a row it acts as a button to call a function with arguments based on the value of the second column in the row.

       

      Is DataGrid the best control to do that? And can that be done? I feel way over my head here and am not sure where to start. Any suggestion, code snippets, etc would be most welcome.

       

      Mike

        • 1. Re: Is DataGrid control the best choice...
          zak.nelson Level 3

          A Datagrid will certainly work, although depending the functionality you require, it may be more overhead than you need. I'd suggest you look at using a list with a custom item renderer. This example would be a good place to start: http://blog.flexexamples.com/2008/01/27/using-a-checkbox-control-as-a-list-item-renderer-i n-flex/ . You could swap out the checkbox for a button or image and respond to a click event on it.

           

          The trickiest part of the example is how to deal with the data in the item renderer:

           

          private function onChange(evt:Event):void {
              data.isSelected = !data.isSelected;
          }
          

           

          This is called when the checkbox is clicked and sets the data of the current item in your data provider. So if you deselected the checkbox of first item in the list the data in arr would change from:

           

           <vo:ListItemValueObject label="One" isSelected="true" />

          to:


          <vo:ListItemValueObject label="One" isSelected="false" />


          Also note that you could just as easily have your data be in the form of XML or ArrayCollection of custom data. Hopefully that helps!

          1 person found this helpful
          • 2. Re: Is DataGrid control the best choice...
            Michael L Hale Level 5

            Thanks for the time and effort of your reply but I'm afraid that it's above my skill level and I could not get it to work.

             

            I think I should give up on creating a panel and just create a ScriptUI dialog for my script.

            • 3. Re: Is DataGrid control the best choice...
              zak.nelson Level 3

              Hmmmm, what aspect is not working? If you replace the standard main.mxml with the mxml provided in the sample and then copy the ListItemValueObject.as in the default package in your source tree then you should be good to go.

               

              I've attached a simple project which illustrates the sample. If you're not using Extension Builder, then you'll have to change some paths to the libraries in the .actionscriptProperties file and move the manifest out of .staged-extension folder.

               

              In general, I find the best way to learn in unfamiliar areas like this is to start with a sample, then tinker with it slowly so you can get an idea of what each component does.

              1 person found this helpful
              • 4. Re: Is DataGrid control the best choice...
                Michael L Hale Level 5

                It wasn't working due to lack of experence on my part. I thought that ListItemValueObject.as needed to be installed as a package. When I moved the file into the src folder it worked.

                 

                I'm using Flex Builder 3 with the CSXSLibrary-2.0 lib. I know that this may be off topic as I'm not using the CS-SDK but here seems to be the best place to ask about using Flex for Adobe apps.

                 

                I agree that it is best to work slowly and as I don't know what to do next to adapt the sample code to my needs perhaps you can recommened a site or documentation where I can get a better understanding of using Flex. If possible I would prefer something releated to creating panels for Adobe apps instead of web or AIR apps.

                 

                Thank you again for your time.