4 Replies Latest reply on Feb 23, 2010 2:42 AM by venkatsyss

    Regarding - Http and Datagrid

    venkatsyss Level 1

      hi,

       

      In Flex I place datagrid in my page and add checkbox in datagrid row   as a Itemrenderer.  Now i need to delete those rows which are checked in grid and gets   deleted on click of the DELETE button. But i am not able to get  deleted  in grid as well as database.

       

       

      Please provide me the solution to solve the problem.

       

      Thanks and Regards,

      venkat.R

        • 1. Re: Regarding - Http and Datagrid
          Gregory Lafrance Level 6

          Clicking the DELETE button should remove data for the selected rows from the DataGrid dataProvider. Then you need to sync the database with the dataProvider.

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          1 person found this helpful
          • 2. Re: Regarding - Http and Datagrid
            venkatsyss Level 1

            hi,

             

            Thanks for your reply.I could not able to find.How i get the multiple selected id from the datagrid and concatenate then i have passed through httpservice.

             

            Please find me solutions to solve the problem.

             

            Thanks and Regards,

            venkat.R

            • 3. Re: Regarding - Http and Datagrid
              flex2008 Level 3

              1)You should have a field in the dataprovider to indicate the selection of checkbox(For eg:if you are using an xmllist you can have an attribute say 'selected' in each item.When you select or deselect the checkbox,set the attribute as true or false accordingly)
              2)Once you click delete button,loop through the dataprovider and get the items where selected == true(or whatever is your "selected" condition).
              3)Use this information to call the service to delete the details from DB.(This step depends on how you are implementing the service,like what are the details that would be needed for the service)
              4)delete the items selected from dataprovider

              • 4. Re: Regarding - Http and Datagrid
                venkatsyss Level 1

                hi,

                 

                Thanks for your kind reply.The following code is not working .please provide me solution to solve the problem.

                 

                My question is how i get the multiple selected checkbox value in httpservice and database in php.

                 

                The following code shows

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                layout="absolute" creationComplete="userRequest.send()">
                <mx:HTTPService id="userRequest" method="POST" useProxy="false"
                url="check.php" result="Display(event)">
                     <mx:request xmlns="">
                         <memid>{uRequest.selectedItem.userid}</memid>
                     </mx:request>
                </mx:HTTPService>

                <mx:Script>
                     <![CDATA[
                         import mx.events.ListEvent;
                         import mx.rpc.events.ResultEvent;
                         import mx.collections.ArrayCollection;
                         import mx.controls.Alert;
                         import mx.controls.DataGrid;
                         [Bindable]private var arr:ArrayCollection;
                         private function Display(event:ResultEvent):void{
                             arr=event.result.users.user;

                        }
                         private function handleSelect(value:Boolean):void
                             {
                                 userRequest.lastResult.users.user.source.forEach(
                                     function callback(item:*, index:int,
                array:Array):void
                                     {
                                         item.sel = value;
                                     });
                                 userRequest.lastResult.users.user.refresh();
                             }
                             private function Update():void{
                                 userRequest.send();
                             }

                    ]]>
                </mx:Script>
                <mx:DataGrid dataProvider="{arr}" id="uRequest" >
                <mx:columns>
                <mx:DataGridColumn>
                     <mx:itemRenderer>
                     <mx:Component>
                         <mx:CheckBox selected="{data.sel}">

                        </mx:CheckBox>
                     </mx:Component>
                </mx:itemRenderer>

                    </mx:DataGridColumn>

                    <mx:DataGridColumn headerText="Sl.No" dataField="userid"></
                mx:DataGridColumn>
                         <mx:DataGridColumn dataField="username">

                        </mx:DataGridColumn>
                         <mx:DataGridColumn dataField="useremail">

                        </mx:DataGridColumn>
                         <mx:DataGridColumn dataField="userstate">

                        </mx:DataGridColumn>

                    </mx:columns>

                </mx:DataGrid>
                <mx:Button label="CheckAll" click="handleSelect(true)">

                </mx:Button>

                <mx:Button label="Update" click="Update()">

                </mx:Button>
                </mx:Application>

                 

                //My Database Query

                 

                if($_POST['memid']!=''){

                        $id=implode(',',$_POST['memid']);

                        $ids=substr($id,0,20);

                        $ans="update tbl_member set member_lname='example' where member_id
                in($ids)";
                         $res=mysql_query($ans);

                        $answer="select * from tbl_member";
                         $result=mysql_query($answer);

                        print "<users>";

                        while($row=mysql_fetch_object($result)){

                        print "<user>
                         <userid>".$row->member_id."</userid>
                         <username>".$row->member_fname."</username>
                         <useremail>".$row->member_lname."</useremail>
                         <userstate>".$row->member_state."</userstate>
                         </user>";

                }

                        print"</users>";

                 

                }

                Please provide me the solution to solve the problem.

                 

                Thanks and Regards,

                venkat.R