ExtJS使用远程JSON存储分页组合。使用分页显示所选值

编程入门 行业动态 更新时间:2024-10-24 04:45:16
本文介绍了ExtJS使用远程JSON存储分页组合。使用分页显示所选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有远程存储的ExtJS组合,它返回JSON格式的数据。当我在第一页上选择一个值(例如),然后导航到另一个页面时,组合显示选择id,而不是值。

I've got an ExtJS combo with remote store, which returns to me data in JSON format. When I select a value on the first page (for example) and then navigate to another page, the combo display selected id, not the value.

如何始终显示所选值?

代码:

Ext.onReady(function() { Ext.define('Model', { extend: 'Ext.data.Model', fields: ['title'], idProperty: 'threadid' }); var store = Ext.create('Ext.data.Store', { pageSize: 50, model: 'Model', remoteSort: true, proxy: { type: 'jsonp', url: 'www.sencha/forum/topics-browse-remote.php', reader: { root: 'topics', totalProperty: 'totalCount' }, simpleSortMode: true } }); var combo = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Value', store: store, queryMode: 'remote', displayField: 'title', valueField: 'threadid', pageSize: 50, labelWidth: 50, width: 300, padding: '60 0 0 0' }); Ext.create('Ext.window.Window', { title: 'Hello', height: 200, width: 400, layout: { type: 'vbox', align: 'center' }, items: combo }).show(); })​

示例: jsfiddle/coshmos/5wT6H/

更多信息(案例研究): 我有一个表,我可以更新记录。我点击一个项目,然后我的服务器从数据库返回值。然后出现一个带有UI的窗口。对于所有分页的组合,它只返回id的。所以,直到我不导航到带有返回ID的项目的页面,我没有看到一个值。如果我禁用分页和加载所有的值,所有的工作按预期,但加载数千个值是不好的。

More information (case study): I've got a table where I can update records. I click on an item and then my server return values from a database. Then a window with UI appear. For all paged combo it's return only id's. So until I don't navigate to page with item with returned id, I don't see a value. If I disable paging and load all values, all works as expected, but loading of thousands values is not good.

推荐答案

可以这样修改:

Ext.override(Ext.form.field.ComboBox,{ findRecord: function(field, value) { var foundRec = null; Ext.each(this.lastSelection, function(rec) { if (rec.get(field) === value) { foundRec = rec; return false; // stop 'each' loop } }); if (foundRec) { return foundRec; } else { return this.callParent(arguments); } } });

试试看: jsfiddle/5wT6H/3/

更多推荐

ExtJS使用远程JSON存储分页组合。使用分页显示所选值

本文发布于:2023-06-13 09:30:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/678928.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分页   组合   所选   ExtJS   JSON

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!