1、问题背景
如果表格中的字段过多,会出现滚动条,在将滚动条滚到一定的位置时,重新刷新表格,滚动条会回到原处,原来查看的字段还得继续滚动,才能查看到。
2、实现实例
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="initHandler(event)" width="100%" height="100%"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.events.FlexEvent; [Bindable] //表格数据绑定 private var gridArray:ArrayCollection = new ArrayCollection([ {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"}, {Jan:"5678",Feb:"7890",Mar:"3454",Apr:"4565",May:"6756",Jun:"5656",Jul:"7867",Aug:"8990",Sep:"5676",Oct:"4655",Nov:"6778",Dec:"8909", Jan1:"3344",Feb1:"5676",Mar1:"7898",Apr1:"9089",May1:"9009",Jun1:"5675",Jul1:"3433",Aug1:"4455",Sep1:"6676",Oct1:"7867",Nov1:"4556",Dec1:"8656"} ]); /** * 初始化函数 */ protected function initHandler(event:FlexEvent):void { } /** * 刷新按钮函数 */ protected function refresh_clickHandler(event:MouseEvent):void { var hx:Object = hsb.left; var hy:Number = hsb.y; //var dx:Number = dataGrid.contentMouseX; //var dy:Number = dataGrid.contentMouseY; //Alert.show("hx:"+hx+"\n"+"hy: "+hy + "\n" + "dx: " + dx + "\n" + "dy: " + dy); Alert.show("hx:"+hx+"\n"+"hy: "+hy); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="20" paddingTop="10" horizontalAlign="center"> <mx:HBox width="100%" height="30"> <s:Label width="100%"/> <s:Button id="refresh" label="刷新" click="refresh_clickHandler(event)"/> </mx:HBox> <mx:DataGrid width="1350" height="90%" id="dataGrid" dataProvider="{gridArray}" horizontalScrollPolicy="on" textAlign="center"> <mx:columns> <mx:DataGridColumn headerText="2013年01月" dataField="Jan" width="200"/> <mx:DataGridColumn headerText="2013年02月" dataField="Feb" width="200"/> <mx:DataGridColumn headerText="2013年03月" dataField="Mar" width="200"/> <mx:DataGridColumn headerText="2013年04月" dataField="Apr" width="200"/> <mx:DataGridColumn headerText="2013年05月" dataField="May" width="200"/> <mx:DataGridColumn headerText="2013年06月" dataField="Jun" width="200"/> <mx:DataGridColumn headerText="2013年07月" dataField="Jul" width="200"/> <mx:DataGridColumn headerText="2013年08月" dataField="Aug" width="200"/> <mx:DataGridColumn headerText="2013年09月" dataField="Sep" width="200"/> <mx:DataGridColumn headerText="2013年10月" dataField="Oct" width="200"/> <mx:DataGridColumn headerText="2013年11月" dataField="Nov" width="200"/> <mx:DataGridColumn headerText="2013年12月" dataField="Dec" width="200"/> <mx:DataGridColumn headerText="2014年01月" dataField="Jan1" width="200"/> <mx:DataGridColumn headerText="2014年02月" dataField="Feb1" width="200"/> <mx:DataGridColumn headerText="2014年03月" dataField="Mar1" width="200"/> <mx:DataGridColumn headerText="2014年04月" dataField="Apr1" width="200"/> <mx:DataGridColumn headerText="2014年05月" dataField="May1" width="200"/> <mx:DataGridColumn headerText="2014年06月" dataField="Jun1" width="200"/> <mx:DataGridColumn headerText="2014年07月" dataField="Jul1" width="200"/> <mx:DataGridColumn headerText="2014年08月" dataField="Aug1" width="200"/> <mx:DataGridColumn headerText="2014年09月" dataField="Sep1" width="200"/> <mx:DataGridColumn headerText="2014年10月" dataField="Oct1" width="200"/> <mx:DataGridColumn headerText="2014年11月" dataField="Nov1" width="200"/> <mx:DataGridColumn headerText="2014年12月" dataField="Dec1" width="200"/> </mx:columns> </mx:DataGrid> <!-- <s:HScrollBar id="hsb" width="100%" viewport="{dataGrid}"/> --> <s:HScrollBar id="hsb" width="100%"/> </mx:VBox> </s:Application>
3、实现结果
问题内容: 我已经创建了JTextpane并在textpane中插入了组件(像Jtextarea这样的组件)。当我在该JTextpane中插入新组件时,JTextpane的Jscrollpane(的垂直滚动条)会自动设置为底部。我想将其设置为最高位置。我怎样才能做到这一点 感谢Sunil Kumar Sahoo 问题答案: 这是我使用的实用程序类。可用于滚动到的顶部,底部,左侧,右侧或水平/垂直中
我试图实现一个无休止的滚动列表视图,但当我调用时,整个列表将刷新,然后滚动位置返回顶部。 这是正常行为吗?我如何让它简单地添加添加的项目而不刷新并保持滚动位置?
本文向大家介绍js实现页面刷新滚动条位置不变,包括了js实现页面刷新滚动条位置不变的使用技巧和注意事项,需要的朋友参考一下 今天因为这个问题困扰了很久网上的例子都尝试没效果,后来发现一点原来是内容最外层没有div的原因 以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持呐喊教程!
问题内容: 我正在尝试实现无穷尽的滚动列表视图,但是当我调用整个列表时,滚动位置将回到顶部。 这是正常现象吗?如何使它简单地添加添加的项目而不刷新并保持滚动位置? 问题答案: 这种行为是不正常的。我看不到您的代码,我建议您执行以下操作: 1)您不是从UI线程调用。正确的方法: 2)您是否偶然拨打了电话 3)在您的适配器中,您重写了方法并添加了说明以转到顶部 4)如果您使用列表来填充适配器- 每次都
本文向大家介绍页面刷新时记住滚动条的位置jquery代码,包括了页面刷新时记住滚动条的位置jquery代码的使用技巧和注意事项,需要的朋友参考一下 @*点击按钮页面刷新的时候 记住滚动条的位置*@
刷新页面后,我无法注销。我认为问题在于获取当前用户的方法或检查用户管理的方法。 管理员授权守卫。服务ts } 使用者服务ts 登录名。组成部分ts 使用者模型ts