9 Replies Latest reply on Sep 23, 2011 2:09 PM by Kristin95762

    unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)

    Kristin95762

      Hi;

       

      I'm loading data from a sqlite table. This column is of course "manufactured" in order to include a checkbox.

       

      How do I fix the "unable to bind" warning?

       

      <mx:DataGridColumn dataField="selected"

                                                    headerText=""

                                                    rendererIsEditor="true"

                                                    editorDataField="selected"

                                                    width="20">

       

                                                                       <mx:itemRenderer>

                                                                                      <fx:Component>

                                                                                                      <mx:Box width="100%" height="100%"

                                                                                                                                         horizontalAlign="center" verticalAlign="middle">

                                                                                                                     <mx:CheckBox selected="{data.selected}" />

                                                                                                      </mx:Box>

                                                                                      </fx:Component>

                                                                       </mx:itemRenderer>

       

                                    </mx:DataGridColumn>

       

      Here's how I load the dataProvider:

       

      private function loadCommentsResult(event:SQLEvent):void

                                    {

                                              var data:Array = selectComments.getResult().data

                                              commentsDP = new ArrayCollection(data);

                                              myDG.dataProvider = commentsDP;

                                    }

       

       

      Thanks

       

      Kristin

        • 1. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
          Flex harUI Adobe Employee

          You might be able to ignore this warning in this scenario.

           

          In general, you should create a ValueObject class with a selected property that supports binding events via or

          • 2. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
            Kristin95762 Level 1

            Hi

             

            I noticed you were linking back to this thread in your response. Did you mean to link to something else?

             

            I'm trying to implement the checkbox so I can delete records from a sqlite table.

             

            That doesn't suggest to me that I need VO's. But, I admit to being ignorant.

             

            I've been studying your SparkCheckBoxDataGrid project. It's a lot to absorb. I can digest bits and pieces, but the overall picture is hard for me to grasp at this time. I've been trying to start out simple and build up as I understand what's going on.

             

            For instance: I had a CheckBox declared as itemRenderer="mx.controls.CheckBox" in the DataGridColumn. That worked fine without causing the binding warning. But it's ugly as the checkbox is not centered in the cell.

             

            When I searched the net to find a way to center the CheckBox (as I have posted in my original question here), I got the binding warnings. So obviously it's the in-line itemRenderer causing the problem. And yes, I have seen the blog about the centered (reusable) checkbox. Again, it's quite advanced for me at this time.

             

            Assuming I can ignore the warning message, I figure I just need to create a loop to check for each selectedItem so I can delete those objects from the database. It occurs to me that I might have trouble collecting this information from an itemRenderer now that I think about it. Is there something else I need to think about here?

             

            Thanks

             

            Kristin

            • 3. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
              Flex harUI Adobe Employee

              The new forum software has some bugs.

               

              In the example, the selectedItems is the set of rows with checked checkboxes.  No need to collect it some other way.

               

              If you create a bindable VO, then it is based on IEventDispatcher and you won’t get warnings.

               

              Didn’t the checkbox in the example show up centered?

               

              -Alex

              • 4. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                Kristin95762 Level 1

                Hello again

                 

                I did some more experimenting. Am I on the right track here???

                 

                Part of the problem of finding code on the net to solve a problem , actually causes new problems.

                 

                In my example code at the top, I literally made up a column that doesn't exist in my data table. I thought this had to be done in order to include a column in the datagrid to house the checkbox. Therefore, because I didn't understand the code I found, my <mx:CheckBox selected="{data.selected}" /> is not tied to any data. That, I assume, is where the problem resides.

                 

                When I tried Code Assist, I discovered the 'selected' property of the checkbox is actually a boolean object (duh).

                 

                So, I changed the selected property to false. And I changed the dataField and editorDataField properties to a column (bookID) in my data table.

                 

                That got rid of my binding warning. I don't know if this is a good thing or not.

                 

                If I am only marking rows to delete, do I need an editorDataField property? I don't want to edit the data except to delete it.

                 

                Do I still need the VO's? That's another hurdle.

                 

                Now, because I have a checkbox, I'm not sure how to retrieve the data associated with it. If I click on a row in the DataGrid (sans checkbox column), I can read the selectedItem data. How does this change with the implementation of the checkbox?

                 

                The checkbox is centered BTW

                 

                Thanks

                 

                Kristin

                 

                PS. I would really like to mark all your responses as helpful, because you are, but I don't know when the appropriate time to award points should be.

                • 5. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                  Flex harUI Adobe Employee

                  If it ain’t broke, don’t fix it.  You don’t need VO’s or editorDataField if everything is working.

                   

                  If you are using my example, the DataGrid’s selectedItems property contains the data items that are checked, and selectedIndicies is the indicies of the items that are checked.  No need to do anything different just because there is a checkbox.

                  • 6. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                    Kristin95762 Level 1

                    Hi

                     

                    Okay, cool.

                     

                    Thank you so much. Little by little it's sinking in.

                     

                    Kristin

                    • 7. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                      Kristin95762 Level 1

                      I have a question about your SparkCheckBoxDataGrid project.

                       

                      I dragged a DataGrid component to my file and compared it to the datagrid in your project. In your project I noticed that you are not using the array of <fx:Object>s defining the data in the table.

                       

                      I've never seen that before.

                       

                      Are you pushing data to the grid somehow?

                       

                      What's the theory on that method?

                       

                      Thanks

                       

                      Kristin

                      • 8. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                        Flex harUI Adobe Employee

                        I’m not quite sure I understood the question.  In the example, the DataGrid has an initialize event handler that calls a method called initDG that sets the data in the datagrid.  This is done to isolate the datagrid from its data.  The data comes from the array I’ve hardcoded, but could come from a server or database.

                         

                        Flash Builder may populate a datagrid with fx:Objects just so you can get a better idea of what the end result will look like, but 99.9% of datagrids actually get their data from a server or database.

                         

                        -Alex

                        1 person found this helpful
                        • 9. Re: unable to bind to property 'selected' on class 'Object' (class is not an IEventDispatcher)
                          Kristin95762 Level 1

                          Okay, yeah.

                           

                          I asked the question too soon. The new Spark DataGrid was new to me and it threw me off.

                           

                          Thanks