EXT ComboBox - Live Search

You heroes, I realize the ComboBox - Live Search, JSON data can be, is not matching, what happened next is how:
JS:
var ds = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: 'test.do?reqCode=list'
        }),
        reader: new Ext.data.JsonReader({
            root: 'ROOT',
            totalProperty: 'TOTALCOUNT',
            id: 'studentname'
        }, [
            {name: 'studentname', mapping: 'studentname'}
        ])
    });
    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
    	 '<tpl for="."><div class="search-item">',
            '<h3>{studentname}</h3>',
        '</div></tpl>'
    );
    
    var search = new Ext.form.ComboBox({
        store: ds,
        minChars:2, 
        displayField:'studentname',
        typeAhead: false,
        loadingText: 'Searching...',
        width: 570,
        pageSize:10,
        hideTrigger:true,
        tpl: resultTpl,
        applyTo: 'search',
        itemSelector: 'div.search-item',
        onSelect: function(record){ // override default onSelect to do redirect
    	alert(record.data.topicId);
    	search.setValue(record.data.topicId);
       // window.location =String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
        }
    });

JSON:
{"TOTALCOUNT":10, "ROOT":[{"rn":1,"studentcode":"xy00000002","studentname":"123456"},{"rn":2,"studentcode":"xy00000003","studentname":"66666"},

{"rn":3,"studentcode":"xy00000004","studentname":"4545"},{"rn":4,"studentcode":"xy00034753","studentname":"Shen Xiaoping "}, {" RN ": 5," studentcode ":" xy00037999 "," studentname ":" Zhu Wenbao"},

{"rn":6,"studentcode":"xy00039017","studentname":"Chen Hao "}, {" RN ": 7," studentcode ":" xy00039123 "," studentname ":" Hu Fengdi "}, {" RN ": 8," studentcode ":" xy00039163 "," studentname ":" Zhu Nengshang"},

{"rn":9,"studentcode":"xy00039245","studentname":"Wang Bing "}, {" RN ": 10," studentcode ":" xy00039769 "," studentname ":" Fu Wang Bin"}]}

Started by Gillian at November 13, 2016 - 8:19 PM

Your remote is loaded, each time to download the data from the server, you need test.do? ReqCode=list passed through the EXT keyword to filter and then return to the data

If you do not want to always loaded from the server, set store to automatically load, combox mode: 'local',
var ds = new Ext.data.Store({ autoLoad: true,


var search = new Ext.form.ComboBox({
store: ds,
mode: 'local',

Posted by Amanda at November 28, 2016 - 8:38 PM