View on GitHub

Sencha Touch 2.x AutoComplete

AutoComplete Extension for input fields

Download this project as a .zip file Download this project as a tar.gz file

Basic Usage

Basic usage example for overlay and remote data request


xtype: 'autocompletefield',
label: 'Stadt',
value: '',
config: {
    resultsDisplay: {
        mode: 'overlay',
    },
	
    autoCompleteRequest: {											
        fields: [
            'id', 'city', 'state', 'county'
        ],
		
        requestType: 'remote',
        proxy: {
            url: 'http://geo.bendspoons.com/',
            extraParams: {
                returnType: 'json',
                token: '123456',
                mode: 'citystraight',
                like: 'true'
            },
            reader: {
                type: 'json',
                rootProperty: 'result'
            },
            paramField: 'city'
        }
    }
}
			

Config

Example "overlay"


xtype: 'autocompletefield',
label: 'Stadt',
value: 'Ha',
config: {
    resultsDisplay: {
        qMinLength: 2,
        itemTpl: 'Custom Tpl: {city}',
        emptyText: 'Custom: No results',
        loadingText: 'Custom: Searching...',
    	
        mode: 'overlay',
        overlayConfig: {
            zIndex: 5,	
            width: 200,
            height: 600,
            inputPlaceHolder: 'Custom: Enter City Name (German Cities)'
        }
    },
	
    autoCompleteRequest: {											
        fields: [
            'id', 'city', 'state', 'county'
        ],
		
        requestType: 'remote',
        proxy: {
            url: 'http://geo.bendspoons.com/',
            extraParams: {
                returnType: 'json',
                token: '123456',
                mode: 'citystraight',
                like: 'true'
            },
            reader: {
                type: 'json',
                rootProperty: 'result'
            },
            paramField: 'city'
        }
    },
	
    itemTapCallback : function(itemData) {
        console.log(itemData);
        alert('Selected: ' + itemData.city);
    }
}
			

Example "inline"


xtype: 'autocompletefield',
label: 'Stadt',
value: '',
config: {
    resultsDisplay: {
        qMinLength: 2,
        itemTpl: 'Custom Tpl: {city}',
        emptyText: 'Custom: No results',
        loadingText: 'Custom: Searching...',
    	
        mode: 'inline',
        inlineConfig: {
            resultsHeight: '300'
        }
    },
	
    autoCompleteRequest: {											
        fields: [
            'id', 'city', 'state', 'county'
        ],

        requestType: 'local', 		// From local source
        proxy: {
            url: 'results.json',
            reader: {
                rootProperty: 'result'
            },
            filterField: 'city'
        }
    },
	
    itemTapCallback : function(itemData) {
        console.log(itemData);
        alert('Selected: ' + itemData.city);
    }
}
			

Credit

Inspired by @martintajurs Sencha Touch 2 Autocomplete Textfield

Support

Any troubles or questions? I'll help if possible: Blog Post with comments