16 Replies Latest reply on Feb 5, 2008 3:04 PM by Arty13

    Alert detail

    GeorgeWS Level 1
      I have an alert to show me items that have been checked in a datagrid with checkboxs.

      Alert.show(includes.toString());

      It seems to work when I check 3 boxs, and press send an alert pops up with [object][Object],[object][Object],[object][Object]. and if I check only 2 only 2 sets of [object][Object] appear. So ity must be doing something right. How can I see what the ID is or put more info so I can see another column to show what ones are checked?

      Thanks
      George
        • 1. Re: Alert detail
          ntsiii Level 3
          [object Object] happens when you attempt to display a complex object in a control that requires text.

          Specify the property of the object that contains the value you want, like:
          myCheckbox.selected;
          Tracy
          • 2. Re: Alert detail
            GeorgeWS Level 1
            Do you mean like this:

            Alert.show(includes.selected);

            includes is the column name the checkbox is in. I dont see how that would display what checkboxs are selected?
            • 3. Re: Alert detail
              ntsiii Level 3
              No, it will not be that easy.

              You will need to loop through the dataProvider, and then build your list based on the item property that is linked to the check box.
              Tracy
              • 4. Re: Alert detail
                GeorgeWS Level 1
                Like this is what Im thinking:

                private function collectForInclude():Array{
                var includes:Array = new Array();
                var obj:Object = new Object();

                for (var i:Number=0 ;i < myDataGrid.dataProvider.length;i ++){
                obj = myDataGrid.dataProvider ;
                if (obj.Include)
                {
                includes.push(obj);
                }
                }

                Alert.show(includes.toString());
                return includes;
                }

                But the aler only shown me [object][Object] for each that has been selected

                Thanks
                • 5. Re: Alert detail
                  Arty13
                  on your includes

                  includes.push(obj);

                  you shouldnt be pushing the dataprovider onto the array, but the item from the dataprovider, so if obj.Include is your item, you should push that onto the array.

                  Hope this helps you some.
                  • 6. Re: Alert detail
                    GeorgeWS Level 1
                    Great thanks that got me further. Now its shown me true,true,true when I check 3 boxes. How can I get it to show me some detail from the datagrid from the other columns. I have the checkbox column, and a customer number column CUSN05. I was hoping to have the alert show me the customer number from CUSN05 when the record is checked.

                    Thanks again every little bit is getting me closer to victory.

                    George
                    • 7. Re: Alert detail
                      Arty13 Level 1
                      When you are doing your check,

                      if (obj.Include)
                      {
                      includes.push(obj.Include);
                      }

                      if you only want the customer number, when you do your push, add the customer number instead of obj.Include. So it would be obj.CUSN05 or whatever the property name is.

                      Hope this helps.

                      Art
                      • 8. Re: Alert detail
                        GeorgeWS Level 1
                        Yes!!! Im so close. I have my DB updating the correct number of checked accounts and adding the form data to each row. I just cant put my colums from my grid. I have this that works to display the fields and data that has been checked in an alert:

                        private function collectForInclude():Array{
                        var includes:Array = new Array();
                        var obj:Object = new Object();
                        for (var i:Number=0 ;i < myDataGrid.dataProvider.length;i ++){
                        obj = myDataGrid.dataProvider ;
                        if (obj.Include)
                        {
                        includes.push(obj.CUSN05);
                        includes.push(obj.DSEQ05);
                        includes.push(obj.CAD105);
                        includes.push(obj.CAD205);
                        includes.push(obj.CAD405);
                        sendFormdata()
                        }
                        }
                        Alert.show(includes.toString());
                        return includes;
                        }

                        Then it fires off the sendFormdata() below:

                        private function sendFormdata():void {
                        var myobj:Object = new Object();
                        myobj.programtype = programtype.text;
                        myobj.status = status.text;
                        myobj.priority = priority.text;
                        myobj.descrip = descrip.text;
                        myobj.followup = followup.selected;
                        myobj.trackcomp = trackcomp.selected;
                        myobj.preslocal = preslocal.selected;
                        myobj.tracksales = tracksales.selected;
                        myobj.startdate = startdate.text;
                        myobj.enddate = enddate.text;
                        myobj.followdates = followdates.text;
                        myobj.itemid = itemid.text;
                        myobj.item = item.selectedLabel;

                        myobj.CUSN05 = itemid.text;

                        cfdataInsert.addData({program:myobj})

                        }

                        This works! I put the myobj.CUSN05 = itemid.text; as a test and I think I can do this...

                        I want to replace the itemid.text from the line above with the includes.push(obj.CUSN05); but I do not know the syntax.

                        Thanks for all the help your the best

                        George
                        • 9. Re: Alert detail
                          Arty13 Level 1
                          George,

                          After seeing more of your code I would personally do this versus what you are doing...

                          private var myArray:Array = new Array();

                          private function collectData():void
                          {
                          //assuming your data provider is an array
                          myDataGrid.dataProvider.forEach("getCheckedData");

                          function getCheckedData(item:*, index:int, array:Array):void
                          {
                          if(item.Include)
                          {
                          myArray.push(item);
                          //assuming CUSN05 is a string
                          sendFormData(item.CUSN05);
                          }
                          }
                          }

                          private function sendFormData(customer:String):void
                          {
                          var myObj:Object = new Object();
                          myObj.programtype = programtype.text;
                          myObj.status = status.text;
                          myObj.priority = priority.text;
                          myObj.descrip = descrip.text;
                          myObj.followup = followup.selected;
                          myObj.trackcomp = trackcomp.selected;
                          myObj.preslocal = preslocal.selected;
                          myObj.tracksales = tracksales.selected;
                          myObj.startdate = startdate.text;
                          myObj.enddate = enddate.text;
                          myObj.followdates = followdates.text;
                          myObj.itemid = itemid.text;
                          myObj.item = item.selectedLabel;

                          myObj.CUSN05 = customer;

                          cfdataInser.addData(myObj);
                          }

                          public function displayData():void
                          {
                          myArray.forEach("alertData");

                          function alertData(item:*, index:int, array:Array):void
                          {
                          var myCUSN:String = item.CUSN05;
                          var myDSEQ:String = item.DSEQ05;
                          // etc... whatever data you have in your DG row

                          Alert.show(myCUSN, "CUSN05 Value");
                          Alert.show(myDSEQ, "DSEQ05 Value");
                          // etc... whatever you want to alert
                          }
                          }


                          I hope this helps you more, I didnt test my code example above, but should be similar to what you are doing.

                          Art
                          • 10. Re: Alert detail
                            GeorgeWS Level 1
                            I dont get it. In the displayData function in your post ended up with this: "
                            I dont know what that should be? So I can not get that part to work.
                            I also get errors with the sendFormData saying possible undefined method.

                            Thanks
                            • 11. Re: Alert detail
                              Arty13 Level 1
                              the error in the sendFormData is probably with this line

                              cfdataInser.addData(myObj);

                              I'm not sure what that function does or what it is expecting, you can change that to whatever you need it to be (also looks like I forgot the 't' at the end in cfdataInser)
                              I just left it there as an example...


                              As for the displayData, what it is supposed to be doing is, instead of pushing individual items onto the array (you had Includes, I had myArray as the array) from a single row, you are pushing an object (the entire row object) onto the array.
                              And when you access the information from the array you will get objects back. This way you can keep the entire row grouped together. But since you are getting the object back, you will have to treat it as an object like you were before. So to access the properties of that row object you will be doing what you did before when you were pushing individual items onto the array,
                              for example...
                              obj.CAD205
                              to access that value

                              Before you were returning the group of values in an array (maybe adding it to another array?) So by assumtion you have arrays in array.
                              I changed that so I had DG row objects in a single array.




                              But if you want to go back to your way that is fine... just pass in the CUSN05 value when you call sendFormdata...
                              For example...

                              **********************

                              private function collectForInclude():Array{
                              var includes:Array = new Array();
                              var obj:Object = new Object();
                              for (var i:Number=0 ;i < myDataGrid.dataProvider.length;i ++){
                              obj = myDataGrid.dataProvider;
                              if (obj.Include)
                              {
                              includes.push(obj.CUSN05);
                              includes.push(obj.DSEQ05);
                              includes.push(obj.CAD105);
                              includes.push(obj.CAD205);
                              includes.push(obj.CAD405);
                              sendFormdata(String(obj.CUSN05))
                              }
                              }
                              Alert.show(includes.toString());
                              return includes;
                              }

                              private function sendFormdata(myCUSN05Value:String):void {
                              var myobj:Object = new Object();
                              myobj.programtype = programtype.text;
                              myobj.status = status.text;
                              myobj.priority = priority.text;
                              myobj.descrip = descrip.text;
                              myobj.followup = followup.selected;
                              myobj.trackcomp = trackcomp.selected;
                              myobj.preslocal = preslocal.selected;
                              myobj.tracksales = tracksales.selected;
                              myobj.startdate = startdate.text;
                              myobj.enddate = enddate.text;
                              myobj.followdates = followdates.text;
                              myobj.itemid = itemid.text;
                              myobj.item = item.selectedLabel;

                              myobj.CUSN05 = myCUSN05Value;

                              cfdataInsert.addData({program:myobj})

                              }

                              *************************

                              I copied your code you posted and changed 3 lines.

                              Hope I've been more help than confusing for ya.

                              Art
                              • 12. Re: Alert detail
                                GeorgeWS Level 1
                                Art,
                                It has become apparent to me that YOU ARE THE KING!

                                One last question. How do I add more columns to this?

                                sendFormdata(String(obj.CUSN05))
                                Im thinking:
                                sendFormdata(String(obj.CUSN05)(objDSEQ05))

                                OK one more...
                                How do you add more to this?
                                sendFormdata(myCUSN05Value:String)

                                Thanks Again - I owe you big time.

                                George

                                • 13. Re: Alert detail
                                  Arty13 Level 1
                                  George,

                                  How much data are you trying to send to your function sendFormData?

                                  is it going to be 2 or more items? [example: CUSN05 and DSEQ05]

                                  and when you say "columns", what do you mean exactly? Are you trying to add two values together?

                                  Art
                                  • 14. Re: Alert detail
                                    GeorgeWS Level 1
                                    Art,

                                    Yes I want to send more data with it. More than 2; all of the columns in the grid so 10. I was refering to the columns as a column in a grid. the CUSN05 is on of the columns in the grid and DSEQ05 is the next one. I have just tried a bunch of stuff to no avail. Thanks again

                                    George
                                    • 15. Re: Alert detail
                                      GeorgeWS Level 1
                                      YES!!!! I got it. A dream come true. Thanks to everyone that helped me, especially Art and Tracy.
                                      • 16. Re: Alert detail
                                        Arty13 Level 1
                                        George,

                                        If you are creating your DG not in a script tag, you can do something like this below...

                                        *****************************

                                        <mx:DataGrid width="100%" height="100%" id="myDataGrid" dataProvider="{myDataCollection}">
                                        <mx:columns>
                                        <mx:DataGridColumn headerText="Name" dataField="name"/>
                                        <mx:DataGridColumn headerText="Size" dataField="size"/>
                                        <mx:DataGridColumn headerText="Type" dataField="type"/>
                                        <mx:DataGridColumn headerText="Date Modified" dataField="datemodified"/>
                                        </mx:columns>
                                        </mx:DataGrid>

                                        **********************

                                        if you are creating your DG within action script, you will need to create a DataGridColumn object and add it to an array and then assign that array to your DG
                                        for example...

                                        ******************

                                        var myDG:DataGrid = new DataGrid();
                                        var myFirstColumn:DataGridColumn = new DataGridColumn("My First Column");
                                        var mySecondColumn:DataGridColumn = new DataGridColumn("My Second Column");
                                        var myThirdColumn:DataGridColumn = new DataGridColumn("My Third Column");

                                        var myColumnArray:Array = new Array();
                                        myColumnArray.push(myFirstColumn);
                                        myColumnArray.push(mySecondColumn);
                                        myColumnArray.push(myThirdColumn);

                                        myDG.columns = myColumnArray;

                                        ****************************

                                        That will add columns, but you still need to assign other properties to the columns before you add it to your array.


                                        As for passing more data to your function, use a comma delimited list...
                                        for example...

                                        ***************************
                                        sendFormdata(String(obj.CUSN05), String(objDSEQ05));

                                        private function sendFormdata(myCUSN05Value:String, myDSEQ05:String):void
                                        ****************************

                                        This gets messy real quick when you have more than about 3 parameters (values you are passing in)
                                        That is why before I suggested passing an object that had all those values already, that way you only had to pass 1 value instead of your 10+

                                        Hope this helps you out.

                                        Art