自动完成组合框ExtJS的远程阿贾克斯店 [英] autocomplete combobox extjs with remote ajax store

查看:173
本文介绍了自动完成组合框ExtJS的远程阿贾克斯店的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序添加一个组合框与远程存储。我有一个商店调用PHP脚本,以JSON格式返回数据,我和我的组合框链接它。
这家店自动载入,但我的组合框仍然是空的。
这里是我的商店

  //定义自动完成模式
Ext.define('modelloAC',{
    延伸:Ext.data.Model',
    领域:
        {名称:'telaio'}
    ]
});
//存储自动完成
VAR autoCompleteStore = Ext.create('Ext.data.Store',{
    型号:modelloAC,
    自动加载:真,
    代理: {
        类型:阿贾克斯,
        网址:'?脚本/ request.php operazione = gettelai',
        读者:{
            类型:'JSON',
            根:威特莱',
            totalProperty:结果
        }
    }
});

我的PHP返回一个JSON数组:

<$p$p><$c$c>{\"results\":207,\"telai\":[{\"telaio\":\"ZAR93200001271042\"},{\"telaio\":\"ZLA84000001738127\"},{\"telaio\":\"VF3WC9HXC33751301\"},{\"telaio\":\"W0L0AHL3555247737\"}]}

我的组合框:

 的xtype:'二合一',
    名称:'telaio',
   // hideTrigger:真实,
   店:autoCompleteStore,
   预输入:真实,
   queryMode:远程,
   fieldLabel:Telaio

我的存储加载完美,但我的组合框是空的,哪来的什么问题?


解决方案

需要补充displayField和valueField在组合配置:

  ...
displayField:telaio',
valueField:telaio',
...

在您的店里还模式目前不确定的。写一个字符串:

  ...
型号:'modelloAC',
...

I want to add a combobox in my app with a remote store. I have a store that call a php script that returns data in json format and I linked it with my combobox. The store is autoLoaded but my combobox is still empty. Here's my store

// Define autocomplete model
Ext.define('modelloAC', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'telaio' }
    ]
});
// store auto complete
var autoCompleteStore = Ext.create('Ext.data.Store', {
    model: modelloAC,
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: 'script/request.php?operazione=gettelai',
        reader: {
            type: 'json',
            root: 'telai',
            totalProperty: 'results'
        }
    }
});

My PHP return a JSON array:

{"results":207,"telai":[{"telaio":"ZAR93200001271042"},{"telaio":"ZLA84000001738127"},{"telaio":"VF3WC9HXC33751301"},{"telaio":"W0L0AHL3555247737"}]}

My combobox:

    xtype: 'combo',
    name: 'telaio',
   //hideTrigger: true,
   store: autoCompleteStore,
   typeAhead: true,
   queryMode: 'remote',
   fieldLabel: 'Telaio'

My store loads perfectly but my combobox is empty, where's the problem?

解决方案

Need to add displayField and valueField in combo config:

...
displayField: 'telaio',
valueField: 'telaio',
...

Also model in your store is undefined now. Write it as a string:

...
model: 'modelloAC',
...

这篇关于自动完成组合框ExtJS的远程阿贾克斯店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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