如何正确加载带有动态数据存储的gridcombobox?

发布于 2024-11-28 16:46:19 字数 1658 浏览 2 评论 0原文

我正在开发一个简单的网格表单,它有一个组合框和数据源作为代理(例如 http://goo.gl/2fxP8)。组合框加载正确,但当我尝试选择列表项之一时,网格窗体关闭,而组合框未关闭。有人能帮我吗?

我还计划扩展组合框 onselect 函数,以便一旦选择列表项,其他字段将被动态加载。

 searchField = new Ext.form.ComboBox({
     store: ds,
     name : 'search',
     id:'search',
     fieldLabel : 'Search',
     displayField:'title',
     typeAhead: false,
     loadingText: 'Searching...',
     pageSize:10, 
     minChars:2,
     triggerAction: 'all',
     width: 200,
     tpl: resTpl,
     itemSelector: 'div.search-item',
     onSelect: function(record){ 
     /* Set Values to other fields here */
     }
 }),

保存的代码是:

                                    Ext.Ajax.request
                                    ({  
                                    url:"some url",
                                    scope:this,
                                    params:
                                    {
                                    },
                                    success: function(objServerResponse)
                                    {
                                        eval("var resultSet = " +objServerResponse.responseText);
                                        if(resultSet.isOk)
                                        {

                                            this.collapse();
                                        }   
                                        else
                                        {


                                        }

                                    }
                                    });

I am working on a simple grid form which has a combobox and datasource as proxy (like http://goo.gl/2fxP8). The combobox loads properly but when I try to select one of the list items the gridform closes and combobox doesn't close. Can anyone help me out ?

I am planning to extend the combobox onselect function as well so that once the list item is chosen other fields will be loaded dynamically.

 searchField = new Ext.form.ComboBox({
     store: ds,
     name : 'search',
     id:'search',
     fieldLabel : 'Search',
     displayField:'title',
     typeAhead: false,
     loadingText: 'Searching...',
     pageSize:10, 
     minChars:2,
     triggerAction: 'all',
     width: 200,
     tpl: resTpl,
     itemSelector: 'div.search-item',
     onSelect: function(record){ 
     /* Set Values to other fields here */
     }
 }),

The code for saving is :

                                    Ext.Ajax.request
                                    ({  
                                    url:"some url",
                                    scope:this,
                                    params:
                                    {
                                    },
                                    success: function(objServerResponse)
                                    {
                                        eval("var resultSet = " +objServerResponse.responseText);
                                        if(resultSet.isOk)
                                        {

                                            this.collapse();
                                        }   
                                        else
                                        {


                                        }

                                    }
                                    });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戴着白色围巾的女孩 2024-12-05 16:46:20

我认为问题是你覆盖了 onSelect 函数..
看看这里(尝试找到onSelect),onSelect 方法是私有的...
正如您所看到的,在 onSelect 内部有一个默认调用的 collapse 函数。
所以,如果你超过了onSelect..默认情况下你的组合永远不会折叠..
你必须手动执行此操作...就像 kiran 所说的...

我的问题是,为什么你要覆盖 onSelect 函数??..
如果您需要做某事,当选择组合时,为什么不将其设置为侦听器?

尝试更改您的代码:

 onSelect: function(record){ 
 /* Set Values to other fields here */
 }

使用以下代码:

listeners : {
   "select" : function(combo,data,idx){
        console.info(data);
   }
}

i think the problem is you are OVERIDE the onSelect function..
take look here (try to find onSelect), onSelect method is private...
and as you can see, inside onSelect there is collapse function to call by default..
so, if you are overide onSelect.. your combo never collapse by default..
you have to do that manually.. like what kiran said...

and my question is, why did you overide the onSelect function ??..
if you need to do something When the combo was selected, why don't you set it as listeners ??

try change your code :

 onSelect: function(record){ 
 /* Set Values to other fields here */
 }

with this one :

listeners : {
   "select" : function(combo,data,idx){
        console.info(data);
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文