`
jacally
  • 浏览: 767445 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

extjs应用:动态组合框

    博客分类:
  • Ajax
阅读更多
extjs御用:动态组合框&远程视频点播负载局部滤波
extjs御用:动态组合框&远程视频点播负载局部滤波
August 20th, 2007 by Angsuman Chakraborty 2007年8月20日,由angsuman chakraborty

In ExtJS you can create ComboBox which loads data from the server.在extjs您可以创建组合框,其中载荷数据从服务器。 You can also code so that new data is loaded from the server in response to an event like changing selection of another ComboBox.您也可以守则,使新的数据是由装在服务器响应一个事件一样,不断变化的选择另一种组合。 However it also means that the filtering is done remotely which is slow.不过这也意味着,过滤,是通过远程控制来完成,这是缓慢的。

In ExtJS ComboBox automatic filtering is a nifty capability where the ComboBox items are automatically filtered to show only the values which matches the text you typed so far.在extjs组合框自动过滤,是一项特殊的能力,如组合框的物品会自动过滤以只显示价值观相匹配的文本,你打字那么远。 It can also auto-fill the rest for you.它也可以自动填写其余的给你。 This powerful capability comes at a price for remote mode.这个强大的能力,在一个价格为远程模式。 Every time the data is filtered by sending a query to the server which can be slower than local query.每一次的数据是经过过滤,派出查询到服务器,可以慢于地方的质疑。

In many use cases the full data is already on the client side, fetched during the initial loading of the ComboBox.在许多情况下使用的全部数据已经在客户端,牵强,在最初的加载的组合。 Subsequent filtering can be easily done on the client side.随后滤波可以很容易地做在客户端。 Let’s see how we can solve it.让我们看看我们如何能够解决这一问题。

Update: I have also filed a更新:我又提出了 defect缺损 in ExtJS forum to hopefully incorporate the functionality in the core with suggested solutions.在extjs论坛,希望把这项功能的核心与解决建议。 The defect details has been provided at the end of this post.该缺陷的详细资料已提供在本月底职位。

The intuitive approach to this problem is to load the ComboBox on an event handler after setting the baseParams of the store with appropriate parameters.直观的办法处理这一问题是装入组合对一个事件处理程序后,订定baseparams的商店与适当的参数。 This works in remote mode but not in local mode.这项工程在偏远模式,而不是在本地模式。 Now you want to set the ComboBox to local mode because you want to implement local filtering, right?现在你想订组合,以本地方式,因为你要执行地方过滤了,对吗?

The solution is far from obvious.解决的办法是远远显而易见的。 In local mode ComboBox clears the filters of the store which in turn replaces the data in the store with the stored, and obviously stale, snapshot.采用本地方式组合框清除过滤器的商店,从而取代了数据存储与储存,显然不新鲜,快照。 To solve this you must call combo.store.updateSnapshot() after the combo.store.load() call.为了解决这个,你必须调用combo.store.updatesnapshot ( )后combo.store.load ( )调用。

Now where can you get this function?现在如果你能得到这个功能呢? Oh yes…哦,是的…

Ext.data.Store.prototype.updateSnapshot = function() {     this.snapshot = this.data; } ext.data.store.prototype.updatesnapshot =功能( ) ( this.snapshot = this.data ; )

The on demand loading is accomplished by keeping the data in local mode and then loading the store once (use a boolean to check) on beforequery event handler.该按需加载是通过保持数据的本地方式,然后再装店一次(使用一个布尔检查) beforequery事件处理器。 You have to use updateSnapshot() function after the load as explained above.你必须使用updatesnapshot ( )函数后负荷正如以上所解释的。

    Use cases 使用案例
    Let’s first look at the use cases which I am sure many will agree with.让我们先看看使用情况下,我相信很多人都会同意。

    1. 1 。 I want to load a ComboBox on demand.我想加载一个组合框上的需求。 I have very large number of columns in a grid, each of which has a ComboBox to help selecting a value.我有相当多的栏目,在一个网格,其中每有一个组合框,以帮助选择了一条价值。 I don’t want to load all the data upfront as that slows down the initial loading.我不想加载所有数据前期那样放慢初始加载。 So I want to load the data when the ComBox drop-down is clicked.所以我想以调用数据时, combox下拉点击。 I can easily do that in remote mode but the downside is that the filtering functionality asks the server for filtering.我可以很容易做到这一点,在偏远的模式,但坏处是过滤功能,要求服务器的过滤。 The data I fetched is fixed and it is already on the client, so there is no justification for bothering the server.数据表明牵强,是固定的,这已是对客户,所以是没有道理的困扰服务器。

    2. 2 。 An alternative scenario is when you have a dynamically loaded ComBox.另一种情况是,当你有一个动态加载combox 。 You would still like to do local filtering, when the data has been fully loaded, for better performance.你仍然会想要做局部滤波,当数据已经满载,有更好的表现。 This might be the one you can better associate with.这可能是一个你可以更好地与之交往。

    Defect 缺损
    My solution was to keep the ComboBox in local mode but load the store on first access.我的解决办法是让各组合框在本地方式,但负荷店首次访问。 This works perfectly in remote mode for the dynamically loading case.这项工程完全可以在偏远模式为动态负荷的情况。 However it doesn’t work when the mode is local.不过它没有工作时的模式,是本地个案。 In local mode the doQuery() calls clearFilter() which replaces the new data in the store with old stale snapshot data.在本地模式doquery ( )调用clearfilter ( )取代,新的数据存储与旧陈腐快照数据。

    What is needed is to replace the snapshot data in this case with the current data in the store after a successful reload.所需要的是,以取代快照数据,在这种情况下,与目前在数据存储成功后,再装。

    The real defect is that in this case clearFilter() shouldn’t replace the store with old snapshot when the store has been refreshed by a call to load.真正的缺陷是,在这种情况下clearfilter ( )不应取代商店与旧的快照时,商店已被刷新,由打电话给负载。

    Solution 解决方案
    My solution was to create a method for this in ComboBox:我的解决的办法是建立一种方法,这在组合框:
    Code:代码:

     Ext.data.Store.prototype.updateSnapshot = function() {     this.snapshot = this.data } ext.data.store.prototype.updatesnapshot =功能( ) ( this.snapshot = this.data )

    And then call this method after loading the ComboBox.然后调用此方法加载后,该组合框。

    The solution works but I am not fully happy as it isn’t elegant.解决工程,但我并不完全感到高兴,因为这不是优雅。 Looking forward to hear a better idea in solving this problem.期待着听到更美好的想法,在这一问题的解决。

    Additional Thoughts 额外的思考
    I think there should be a way for clearFilter() to recognize when new data has been loaded versus when filtered data has been loaded for the old data.我觉得应该有一种方式clearfilter ( )承认,当新的数据已被装银两时,过滤数据已经加载为旧数据。 Both cases uses load().这两种情况下使用负荷( ) 。
    The solution could be a new configuration parameter to load() which clearFilter() looks for and processes, if available.解决方案可能是一个新的配置参数,以负荷( ) ,其中clearfilter ( )的面貌和进程,如果有的话。
分享到:
评论
1 楼 379548695 2008-10-13  
远程数据自动匹配到底怎么搞啊。?

相关推荐

    ExtJS扩展:lovcombo(已解决Bug版)

    `lovcombo`的全称为“联动下拉组合框”,它的核心功能是实现两个或多个下拉框之间的数据联动,通常用于数据库中一对多或多对多关系的数据输入场景。例如,一个下拉框选择了国家,另一个下拉框则根据所选国家展示相应...

    extjs4.2目录框架

    【标题】"extjs4.2目录框架"指的是基于Ext JS 4.2版本构建的前端用户界面框架,用于组织和展示应用程序的目录结构。在Web应用开发中,目录框架通常用于提供清晰的导航和组织复杂的业务逻辑。Ext JS是一个强大的...

    ExtJs Google Suggest 动态查询效果

    首先,我们要理解ExtJs的核心组件之一——ComboBox(组合框)。ComboBox结合了文本输入框和下拉列表,通常用于提供预定义的选项供用户选择。在这个案例中,ComboBox被定制以实现动态查询功能,即根据用户的输入实时...

    SSH+Extjs框架

    SSH+ExtJS框架是Web应用开发中的一个常见组合,它结合了Struts2、Hibernate和Spring三大主流Java EE框架,并引入了ExtJS作为前端展示层技术。这个框架的使用大大提高了开发效率,提供了灵活的数据管理和用户界面交互...

    extjs应用框架

    在深入探讨ExtJS应用框架之前,我们先了解其核心概念。 1. **整体结构**: ExtJS的应用通常由以下几个主要部分组成: - **CSS样式表**:用于定义组件的外观和布局。 - **JavaScript库**:包括核心库(Core)和...

    ExtJs应用

    Ext Js是一种广泛应用于Web开发的JavaScript库,专为构建富客户端应用程序而设计。它提供了丰富的组件库、数据绑定机制和可扩展的架构,使得开发者能够创建功能强大的、交互性强的Web应用。本压缩包文件包含的是Ext ...

    extjs 3.2三大框架小类字

    ExtJS 3.2是Sencha公司开发的一款用于构建富客户端Web应用的JavaScript库,它提供了丰富的组件和强大的数据绑定机制。SSH(Spring、Struts、Hibernate)则是一种常见的Java Web开发框架组合,用于处理后端业务逻辑和...

    组合框combo里面change和click的区别

    在VB(Visual Basic)编程中,组合框(ComboBox)是一种常用的控件,它允许用户从一组预定义的选项中进行选择。在处理用户交互时,我们可能会遇到两种常见的事件:`Change` 和 `Click`。了解它们之间的区别是编写...

    EF+EXTJS+MVC+oracle框架

    综上所述,"EF+EXTJS+MVC+Oracle框架"是一个高效且全面的开发组合,它涵盖了数据访问、前端用户界面、应用结构和后台数据存储的关键环节,为企业级应用开发提供了坚实的基础。开发者可以根据具体需求,灵活运用这些...

    ajax框架之extjs2.0

    ExtJS 2.0是一个基于JavaScript的开源AJAX框架,专为构建富互联网应用程序(RIA)而设计。它提供了一套完整的组件模型、数据绑定机制、丰富的用户界面控件和强大的API,使得开发者能够轻松创建功能强大且交互性强的...

    ExtJS_MVC框架的搭建实例

    ExtJS是一款基于JavaScript的开源前端框架,主要用于构建企业级的Web应用程序。它提供了大量的UI组件库,包括表格、网格、表单等,并支持拖拽、动画等功能。ExtJS采用了MVC(Model-View-Controller)架构模式,使得...

    Extjs3 多选下拉框LovCombo

    3. **自定义模板**:可以定制显示模板,决定如何在下拉列表和组合框中展示每个选项。 4. **配置灵活性**:支持各种配置项,如fieldLabel(字段标签)、store(存储数据的源)、displayField(显示字段)、...

    Extjs中常用表单介绍与应用

    在实际应用中,表单面板的综合应用通常会涉及到各种表单组件的组合使用,以及表单提交数据的处理。例如,使用fieldset来对相关字段进行逻辑分组,使用按钮来提交表单数据等。通过灵活运用ExtJS的表单组件,可以创建...

    extjs3.0框架

    4. **表单组件**:ExtJS提供了丰富的表单组件,如文本框、下拉框、复选框、单选按钮等,以及用于验证和提交表单的工具。这些组件支持自定义样式和事件处理,可以轻松创建复杂的表单界面。 5. **数据网格**:ExtJS的...

    下拉(条件)搜索实例extjs4.2(亲测可用).zip

    在ExtJS应用中,它可能包含了自定义的样式、函数或者其他特定于这个实例的配置。 总的来说,这个实例展示了如何使用ExtJS 4.2来创建一个功能丰富的Web应用,结合了下拉菜单和条件搜索,同时利用PHP后端处理数据请求...

    资料:包括extjs2.0源码

    5. **表单元素**:EXTJS 2.0提供了丰富的表单元素,如文本框、下拉框、复选框等,支持验证和联动效果,方便构建动态表单。 6. **图表组件**:EXTJS 2.0内置了各种图表类型,如柱状图、饼图、线图等,适用于数据可视...

    extjs-2.2开发框架

    1. **组件化开发**:ExtJS的核心在于其组件模型,它允许开发者通过组合各种预先定义好的组件(如表格、表单、树、面板等)来构建复杂的用户界面。这些组件具有高度可配置性和可重用性,极大地提高了开发效率。 2. *...

    SSH框架下extjs 的使用

    2. **创建ExtJS应用**:基于ExtJS的Application类,定义应用程序的基本结构,包括启动函数、命名空间和扩展组件。这将作为整个前端应用的入口。 3. **设计视图组件**:利用ExtJS的组件模型,可以创建各种类型的UI...

    extjs电子教材,开发extjs框架的好东西

    EXTJS是一种基于JavaScript的前端开发框架,用于构建富互联网应用程序(RIA)。它的全名是Ext JavaScript Library,由Sencha公司开发。EXTJS以其强大的组件化、丰富的用户界面和高度可定制性著称,广泛应用于企业级...

Global site tag (gtag.js) - Google Analytics