开发者

how to fix Gridview after reloading Grid in Adobe flex

i have searched a lot but could not find the exact way to do this... you will understand better if you will look once this page. freescale .please open this in IE.Here is my scenario...

click om power Actuation present in leftnav under Analog & Power Management. you will get result table and above that i have a container which shows different filter criteria. now find a filterable header(match header name with filter header) that is out of the screen fold to the right.then Choose a value for filter exercise, filter by it.

now here my problem arises

after reloading the results, the table-vi开发者_JS百科ew comes back to it's starting position, which creates the confusion to end user about the results.

so my question is how can i prevent my table-view to gets back to it's starting point?

i want my result should appear like this..

Value is chosen for filtering, filtering starts, the reloaded values appear in the same screen position, as before the value was chosen

i thought about viewStack but could not figure about how to do?

any suggestion or solution will highly appreciated!!!!!

Thanks in advance for your valuable time which you spend to read my question.


Store the 'horizontalScrollPosition' of the datagrid in a variable as soon as you click the filter.Then after loading the data in the table, reset the horizontalscrollposition back.

I have provided an example below.In this example there is a datagrid and a button. On click of the button data gets loaded and I maintain the scroll position by setting the 'horizontalScrollPosition' value after loading the data.

<mx:DataGrid id="dataGridsfgh"
             left="15"
             top="41"
             dataProvider="{employeeList}"
             width="100%"
             horizontalScrollPolicy="on">
    <mx:columns>
        <mx:DataGridColumn headerText="First Name"
                           dataField="firstname"
                           width="40"/>
        <mx:DataGridColumn headerText="Last Name"
                           dataField="lastname"
                           width="40"/>
        <mx:DataGridColumn headerText="Designation"
                           dataField="designation"
                           width="40"/>
        <mx:DataGridColumn headerText="Contact # (Desk)"
                           dataField="deskphone"
                           width="40"/>
        <mx:DataGridColumn headerText="Contact # (Mobile)"
                           dataField="mobilephone"
                           width="40"/>
        <mx:DataGridColumn headerText="Contact # (Home)"
                           dataField="resphone"
                           width="40"/>
        <mx:DataGridColumn headerText="Address"
                           dataField="address1"
                           width="40"/>
        <mx:DataGridColumn headerText="Address"
                           dataField="address2"
                           width="40"/>
        <mx:DataGridColumn headerText="State"
                           dataField="state"
                           width="40"/>
        <mx:DataGridColumn headerText="Zip"
                           dataField="zip"
                           width="40"/>
        <mx:DataGridColumn headerText="Country"
                           dataField="country"
                           width="40"/>
    </mx:columns>
</mx:DataGrid>
<mx:Button x="36"
           y="228"
           label="Save position"
           click="addData();"/>

Actionscript Code:

    private function addData():void
        {
            var temp:int=dataGridsfgh.horizontalScrollPosition;
            var employeeObj:Object=new Object();
            employeeObj.firstname="John";
            employeeObj.lastname="Henry";
            employeeObj.designation="Developer";
            employeeObj.deskphone="XXX-XXX-XXXX";
            employeeObj.mobilephone="XXX-XXX-XXXX";
            employeeObj.resphone="XXX-XXX-XXXX";
            employeeObj.address1="#XXX Seawall Blvd";
            employeeObj.address2="Apt # XXX";
            employeeObj.location="Maui";
            employeeObj.state="Hawaii";
            employeeObj.zip="XXXXX";
            employeeObj.country="U.S";
            employeeList.addItem(employeeObj);
            dataGridsfgh.dataProvider=employeeList;
            dataGridsfgh.invalidateDisplayList();
            dataGridsfgh.horizontalScrollPosition=temp;
        }

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜