2 Replies Latest reply on Aug 3, 2011 5:32 AM by jfb00

    Datagrid scrollToIndex issue

    jfb00 Level 3

      Hi All,

      I have a tab navigator with 3 canvas, in each canvas I have a datagrid displaying the same record id's with some different data. If i click in one of the datagrid row I am selecting the same index row in the other two datagrids.

      My issue is when I select a row using high number with scroll. To show the same row in the other two datagrids I am using scrollToIndex but the it is not working until I select the datagrid first, after that it works fine.

      I try using validateNow() like this example but no luck:

      http://www.anujgakhar.com/2007/12/28/flex-how-to-pre-select-an-item-in-datagrid/

      Any ideas?

      Thanks

       

      JFB

        • 1. Re: Datagrid scrollToIndex issue
          Flex harUI Adobe Employee

          Post a 20-line test case.

          • 2. Re: Datagrid scrollToIndex issue
            jfb00 Level 3

            Hi Alex,

            I did create a test with structure of my app and it works fine after setting creationPolicy all in the tab navigator.

            I try the same in my main app and it is not working , I try setting creationPolicy in all tab navigators and no luck, still the same, it works after selecting the other datagrids.

            How can I debug this issue?

            Thanks for you reply and help.

             

            JFB

             

            Here is my test code:

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
                <mx:Script>
                    <![CDATA[
                        import mx.collections.ArrayCollection;
                        import mx.events.ListEvent;
                        
                        [Bindable] private var acSample2:ArrayCollection = new ArrayCollection;
                        private var TotalTYCOM:Number = 0;
                        
                        [Bindable] private var acSample:ArrayCollection = new ArrayCollection([
                            {Fname: "Kranthi", Lname:"Kata", dob:"21/10/1972", Amount:10000, Rate:0},
                            {Fname: "Vasanth", Lname:"Lola", dob:"12/01/1980", Amount:5000, Rate:0},
                            {Fname: "Sample1", Lname:"Lola", dob:"12/01/1982", Amount:10000, Rate:0},
                            {Fname: "Basanth", Lname:"Viola", dob:"5/01/1980", Amount:5000, Rate:0},
                            {Fname: "Sample2", Lname:"Viola", dob:"2/06/1985", Amount:10000, Rate:0},
                            {Fname: "Manoj", Lname:"Pati", dob:"16/09/1978", Amount:5000, Rate:0},
                            {Fname: "John McClain", Lname:"Mela", dob:"15/01/1974", Amount:10000, Rate:0},
                        ]);
                        
                        private function setADGRow(event:ListEvent):void{
                            var rowIndex:Number = event.rowIndex;
                            total_dg.selectedIndex = rowIndex;
                            first_dg.selectedIndex = rowIndex;
                            second_dg.selectedIndex = rowIndex;
                            
                            total_dg.validateNow();
                            first_dg.validateNow();
                            second_dg.validateNow();
                            
                            total_dg.scrollToIndex(rowIndex);
                            first_dg.scrollToIndex(rowIndex);
                            second_dg.scrollToIndex(rowIndex);
                        }
                    ]]>
                </mx:Script>
                <mx:TitleWindow width="100%" height="100%" layout="absolute" title="Summary" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                    <mx:TabNavigator id="firstLevel" width="100%" height="100%">
                        <mx:Canvas id="one" label="ONE" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                            
                        </mx:Canvas>
                        <mx:Canvas id="two" label="TWO" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                            
                        </mx:Canvas>
                        <mx:Canvas id="three" label="THREE" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
                            <mx:TabNavigator width="100%" height="100%">
                                <mx:Canvas id="AA_ONE" label="FIST" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                    <mx:TabNavigator id="firstTabNav" width="100%" height="100%" creationPolicy="all" >
                                        <mx:Canvas label="Totals" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            
                                        </mx:Canvas>
                                        <mx:Canvas label="First" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            
                                        </mx:Canvas>
                                        <mx:Canvas label="Second" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            
                                        </mx:Canvas>
                                    </mx:TabNavigator>
                                </mx:Canvas>
                                <mx:Canvas id="AA_TWO" label="SECOND" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                    <mx:TabNavigator id="secondTabNav" width="100%" height="100%" creationPolicy="all" >
                                        <mx:Canvas label="Totals" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            <mx:AdvancedDataGrid id="total_dg" dataProvider="{acSample}" x="10" y="10" width="890" height="150" editable="false" itemClick="setADGRow(event)"
                                                                 sortableColumns="false" headerHeight="40" lockedColumnCount="1" >
                                                <mx:columns>
                                                    <mx:AdvancedDataGridColumn headerText="FIRST NAME" dataField="Fname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="LAST NAME" dataField="Lname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="DOB" dataField="dob" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="TOTAL" dataField="Amount" width="100" textAlign="right" />
                                                </mx:columns>
                                            </mx:AdvancedDataGrid>
                                        </mx:Canvas>
                                        <mx:Canvas label="First" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            <mx:AdvancedDataGrid id="first_dg" dataProvider="{acSample}" x="10" y="10" width="890" height="150" editable="false" itemClick="setADGRow(event)"
                                                                 sortableColumns="false" headerHeight="40" lockedColumnCount="1" >
                                                <mx:columns>
                                                    <mx:AdvancedDataGridColumn headerText="FIRST NAME" dataField="Fname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="LAST NAME" dataField="Lname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="DOB" dataField="dob" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="TOTAL" dataField="Amount" width="100" textAlign="right" />
                                                </mx:columns>
                                            </mx:AdvancedDataGrid>
                                        </mx:Canvas>
                                        <mx:Canvas label="Second" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                            <mx:AdvancedDataGrid id="second_dg" dataProvider="{acSample}" x="10" y="10" width="890" height="150" editable="false" itemClick="setADGRow(event)"
                                                                 sortableColumns="false" headerHeight="40" lockedColumnCount="1" >
                                                <mx:columns>
                                                    <mx:AdvancedDataGridColumn headerText="FIRST NAME" dataField="Fname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="LAST NAME" dataField="Lname" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="DOB" dataField="dob" width="150" />
                                                    <mx:AdvancedDataGridColumn headerText="TOTAL" dataField="Amount" width="100" textAlign="right" />
                                                </mx:columns>
                                            </mx:AdvancedDataGrid>
                                        </mx:Canvas>
                                    </mx:TabNavigator>
                                </mx:Canvas>
                            </mx:TabNavigator>
                        </mx:Canvas>
                        
                    </mx:TabNavigator>
                </mx:TitleWindow>
            </mx:Application>