Hi Sanjay,
  Thanks lot for you reply. Please share that piece of code where in 
you are storing the index of selected row at the respective index of 
array.
How did you u get the row which need to be selected, are you also 
calling a method on mouseOver function.
I desperately need this functionality in my project. Please share 
your sample app if possible or have a look in my code below, please 
point me to the location where I need to focus.
 
 
Regards,
Dharmendra
 
<?xml version="1.0" encoding="utf-8"?>

 

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute" creationComplete="init()"

      backgroundColor="#b3b4ae" >

 

      <mx:Script >

            <![CDATA[

                  import mx.charts.HitData;

                  import 
mx.controls.dataGridClasses.DataGridItemRenderer;

                  import mx.events.ListEvent;

                  import flash.utils.describeType;

                  import flash.utils.getDefinitionByName;

                  import mx.controls.Alert;

                  import mx.formatters.DateFormatter;

                  import mx.collections.ArrayCollection;

                  // include "MatsFormatter.as"

             var selectedArr:Array = new Array();

           var arrCol:ArrayCollection     ;           

            function init():void{

            

            

             arrCol = new ArrayCollection([{name:'AA', age:25}, 
{name:'BB', age:15}, 

                                       {name:'CC', age:23},
{name:'DD', age:25}, {name:'EE', age:15}, 

                                       {name:'FF', age:23},
{name:'GG', age:25}, {name:'HH', age:15}, 

                                       {name:'II', age:23}]);

            

            dg.dataProvider = arrCol;

            }

                  

            var isMouseDown:Boolean = false;

                  

            public function mouseDownFunc
(mDn:flash.events.MouseEvent  ):void{

            //Alert.show("mouseDownFunc");

            isMouseDown = true;

            }

 

            public function mouseUpFunc
(mUp:flash.events.MouseEvent  ):void{

             // Alert.show("mouseUpFunc");

               isMouseDown = false;

               // Work Around to select iterleaved unselected row 

             /*   var selectedArr2:Array = new Array();

               var firstRowIndex :int = dg.selectedIndices[0]

               var lastRowIndex :int = dg.selectedIndices
[dg.selectedIndices.length -1 ]

               if(firstRowIndex < lastRowIndex){

                  for(var i:int = firstRowIndex; firstRowIndex<= 
lastRowIndex;firstRowIndex++)

                       selectedArr2.push(firstRowIndex);

               }else{

                  for(var j:int = lastRowIndex; lastRowIndex<= 
firstRowIndex;lastRowIndex++)

                      selectedArr2.push(lastRowIndex);

                }

               dg.selectedIndices = selectedArr2; */

            }

 

            public function mouseOverFunc
(mOver:MouseEvent,dgCol:ListEvent = null ):void{

              var  rend:Object;

              if(isMouseDown){

               try{

               selectedArr = dg.selectedIndices;

               selectedArr.push(mOver.target.listData.rowIndex); 

               dg.selectedIndices = selectedArr;

             

               

              }catch(e:Error){

              //  rend = mOver.relatedObject ; 

               

               }

              }

           }

           //   Deprecated 

/*       public function itemRollOverFunc(itmRollOver:ListEvent):void
{

              if(isMouseDown){

                     try{

                     selectedArr = dg.selectedIndices;

                     selectedArr.push(itmRollOver.rowIndex); 

                     dg.selectedIndices = selectedArr;

                    }catch(e:Error){

                     trace(e.getStackTrace());

                    }

                   }

          }  */

 

            ]]>

            

      </mx:Script> 

      

    <mx:Style>

          DataGrid {

           backgroundColor:#b3b4ae; 

           borderColor:#66696B;

           verticalGridLineColor :#808080;

           horizontalGridLineColor :#808080;

           themeColor:#0A246A;

           borderStyle:solid;

           fontSize: 8;

           headerStyleName: "dgHeaderStyles";

          }

        .dgHeaderStyles {

            fontSize: 10;

            textAlign: left;

            backgroundColor: #d4d0c8;

            fontFamily :san Sarif;

    

          }

 

         

     </mx:Style>

       <!--mouseDown="mouseDownFunc(event)"  mouseUp="mouseUpFunc
(event)" mouseOver="mouseOverFunc(event)"-->

<mx:Panel layout="absolute" title="MATS Trade Management Console" 
id="gridPanel" left="5" right="5" top="5" bottom="5" 
themeColor="#B3B4AE">

      <mx:DataGrid width="50%" height="50%" 
headerColors="[#d4d0c8,#d4d0c8]" horizontalScrollPolicy="auto" 
allowMultipleSelection="true" id="dg"

                   horizontalGridLines="true"    rowHeight="30"

                 selectionColor="#FFFFFF"           top="0" 
bottom="0"  

                 mouseDown="mouseDownFunc(event)"  
mouseUp="mouseUpFunc(event)" mouseOver="mouseOverFunc(event)"

                 

               >

              <mx:columns>

                  <mx:DataGridColumn         id="status" 
wordWrap="false"  headerText="Name " dataField="name"/>

                  <mx:DataGridColumn          id="age"  
dataField="age"      headerText="Age"/>

              </mx:columns>               

               

      

      </mx:DataGrid>

 

</mx:Panel>

 

</mx:Application>

 


 
 
 
 
 
 
 
 
 
 
 
 



--- In [email protected], "sanjaypmg" <sanjay...@...> wrote:
>
> Hello Dharmendra,
> 
> I have done this type of functionality in Flex 2. That 
functionality
> was like :: User can select multiple rows on a single click without
> pressing SHIFT key  and when user again click on the selected row 
it
> gets deselected. for that functionality I have not override any
> method. I have just created a method & Array as you have done and
> stored the index of selected row at the respective index of array.
> thereafter asigned that array to DG's selectedIndices.
> 
> 
> Cheers....
> Sanjay Sharma
> 
> --- In [email protected], "Dharmendra Chauhan"
> <chauhan_icse@> wrote:
> >
> > Hello,
> >      I have designed a custom dataGird which allows user to 
select 
> > multiple row without shift key. that meas user just need to 
right 
> > click the mouse and drag it over the grid.  For this I have 
> > override  mouseOverHandler Function in my dataGrid.
> > 
> >   override protected function mouseOverHandler
(event:MouseEvent):void
> > {
> >          var selectedArr:Array = new Array();
> >              if(isMouseDown){ 
> > 
> >                try{ 
> > 
> >                selectedArr = dg.selectedIndices; 
> > 
> > 
> >                selectedArr.push(mOver.target.listData.rowIndex); 
> > 
> > 
> >                dg.selectedIndices = selectedArr; 
> > 
> > 
> >               }catch(e:Error){ 
> >                } 
> >               }
> >        }
> > 
> > Issue wich I have been facing 
is  'mOver.target.listData.rowIndex'  
> > does not  consistently  return rowIndex ,whenever I move mouse 
with 
> > fast pace   
> > 1 ) it throws an error  " Property listData not found on 
> > mx.controls.listClasses.ListBaseContentHolder 
> > and there is no default value" .
> > 2) Some dataGrid does not dispatch mouseOver as a result 
> > mouseUpHandler does get called.
> > I hope you are convinced with observation.Please let me know you 
> > have any workAound for the above issue. 
> > 
> > Regards,
> > Dharmendra
> >
>


Reply via email to