IE中的ExtJS组合框问题 [英] ExtJS combobox problem in IE

查看:177
本文介绍了IE中的ExtJS组合框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ExtJS组合框,后面有一个远程数据存储。在所有浏览器中,除了IE(所有已测试的版本)之外,所有的浏览器都可以正常工作,这个组合框扩展了一个分段,显示一个加载图标,然后再次消失。在此之后再次单击它不会使其扩展。基本上:它没有被填充。



在服务器端,一切都很好。 Controller操作达到(使用ASP.NET MVC)返回Json数据。 Json是正确的(所有其他浏览器至少吞下它)。



一个奇怪的是,当我在Controller操作中放置一个断点时,JsonStore在客户端正确填充。这对我来说表示某种时间问题。



另一个奇怪的是,每隔一段时间,它工作正常。也许是因为时间恰好是意外或某事。



如果我将组合框模式设置为本地,并强制一个 .load() 在远程数据存储上,它也可以在IE中正常工作。



此问题出现在我们使用远程数据存储的所有组合框中。



我有以下JsonStore :

  var companies = new Ext.data.JsonStore({
url:'/ Company / GetCompanies /',
root:'Companies',
fields:[
{name:'CompanyID'},
{name:'CompanyName'}]
});

组合框:

  new Ext.form.ComboBox({
fieldLabel:'Company',
typeAhead:false,
triggerAction:'all',
valueField:'CompanyID ',
hiddenName:'CompanyID',
displayField:'CompanyName',
mode:'remote',
lazyRender:true,
store:companies,
allowBlank:true,
可编辑:false,
监听器:{
'focus':function(){
if(enterprises.data.length> 0)
{
debugger; //这只是在上述断点方法之后才被触发
}
}
}
})

控制器返回的Json:

 code> {company:[{CompanyID:1,CompanyName:Test},{CompanyID:2,CompanyName:Test1
},{CompanyID :3,CompanyName:Test2}}}


解决方案

数字,我发布了一个问题后解决了解决方案。



我切换到一个商店而不是JsonStore,并指定代理的方法:'GET'属性,它的工作。我不知道为什么这样工作虽然,为什么只有IE有问题。我的控制器操作接受GET和POST,所以不是这样。



商店:

  var companies = new Ext.data。存储({
proxy:new Ext.data.HttpProxy({url:'/ Company / GetCompanies /',method:'GET'}),
reader:new Ext.data.JsonReader({root :'company'},[{name:'CompanyID',mapping:'CompanyID'},{name:'CompanyName',mapping:'CompanyName'}])
});


I have an ExtJS combobox with a remote data store behind it. In all browsers it works fine, except in IE (all versions that I've tested) where the combobox expands for a splitsecond, showing a "loading" icon and then it disappears again. Clicking it again after this doesn't make it expand at all anymore. Basically: it's not being populated.

On the server side, everything is fine. The Controller action is reached (using ASP.NET MVC) which returns Json data. The Json is properly formed (all other browsers swallow it at least).

A weird thing is, that when I put a breakpoint in the Controller action, the JsonStore is properly filled on the client side. This to me indicates some sort of timing problem.

Another weird thing is that, every once in a while, it works fine. Perhaps because the timing is just right by accident or something.

If I set the combobox mode to 'local' and force a .load() on the remote datastore, it works fine in IE too.

This problem is present in all comboboxes that use a remote datastore for us.

I have the following JsonStore:

  var companies = new Ext.data.JsonStore({
    url: '/Company/GetCompanies/',
    root: 'companies',
    fields: [
    { name: 'CompanyID'},
    { name: 'CompanyName'}]
  });

The combobox:

new Ext.form.ComboBox({
    fieldLabel: 'Company',
    typeAhead: false,
    triggerAction: 'all',
    valueField: 'CompanyID',
    hiddenName: 'CompanyID',
    displayField: 'CompanyName',
    mode: 'remote',
    lazyRender: true,
    store: companies,
    allowBlank: true,
    editable: false,
    listeners: {
        'focus': function(){
          if(companies.data.length > 0)
          {
           debugger; // This is only ever fired after the aforementioned breakpoint method.
          }
        }
    }
})

The Json that is returned by the Controller:

{"companies":[{"CompanyID":1,"CompanyName":"Test"},{"CompanyID":2,"CompanyName":"Test1"
},{"CompanyID":3,"CompanyName":"Test2"}]}

解决方案

Figures, I work out the solution just minutes after posting a question about it.

I switched to a Store instead of a JsonStore and specified the method: 'GET' property of the proxy and it worked. I have no clue why this does work though, and why only IE had a problem with it. My Controller action accepts both GET and POST so that wasn't it.

The Store:

var companies = new Ext.data.Store({
      proxy: new Ext.data.HttpProxy({ url: '/Company/GetCompanies/', method: 'GET' }),
      reader: new Ext.data.JsonReader({ root: 'companies' }, [{ name: 'CompanyID', mapping: 'CompanyID' }, { name: 'CompanyName', mapping: 'CompanyName'}])
});

这篇关于IE中的ExtJS组合框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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