如何从ComboBox(ExtJS)中的商店中选择一个特定的记录 [英] How to select a specific record from the store in a ComboBox (ExtJS)

查看:70
本文介绍了如何从ComboBox(ExtJS)中的商店中选择一个特定的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有远程json存储的组合框。

I have a ComboBox with a remote json store.

它允许用户键入3个字符,然后键入查询,显示列表,并允许用户选择一个选项。当用户选择一个选项时,它使用与选定选项关联的Ext.data.Record来填充表单其他位置的其他字段。这样可以正常工作。

It lets the user type in 3+ characters, then queries, displays list and lets user select one option. When the user selects an option, it uses the Ext.data.Record associated to the selected option to populate other fields elsewhere in the form. This works correctly.

现在,我想通过使用已经编写的作为组合框的一部分的功能来预先填充所述字段。我想到的是在ComboBox的商店添加一个人造记录,然后强制其选择 - 这将触发所有正确的功能并填充其他字段等。

Now I want to be able to pre-populate the said fields, by using the functions that I've already written as part of the combo box. What I have come up with, is to add an "artificial record" to the ComboBox's store, and then force its selection - which would trigger all the right functions and populate the other fields etc..

我有这个功能在ComboBox里面(我已经通过扩展ComboBox创建了一个定制的):

What I have is this function inside of the ComboBox (I've created a custom one by extending ComboBox):

loadRecord : function( record ){
    var data = {
        "results":1,
        "rows":[
            record
        ]
    }

    this.store.loadData( data ); // I realize I could just use store.add() instead.

    alert( this.store.getCount() ); // returns 1, so the record is in

    // Here is where I'd need to make a call to select this record.
}

我已经尝试过this.select()和this.selectByValue()无济于事知道记录在商店里,从代码中选择什么是正确的方法?

I've tried this.select() and this.selectByValue() but to no avail. Knowing the record is in the store, what is the right way to select it from code?

提前谢谢。

推荐答案

你尝试过 combo.fireEvent('click',combo,record,index)

这篇关于如何从ComboBox(ExtJS)中的商店中选择一个特定的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆