PDA

View Full Version : Help with auto suggest in Ext.form.ComboBox



abhishek4
26 Apr 2013, 8:11 AM
Hi,


We are using Ext.form.ComboBox with auto suggest feature where in we make the call yo backend when some test is entered in the text area. Our servers don't allow apostrophe "'" in the url request for for stopping cross -site script attacks.


I want to escape all the apostrophe that we type in the text bos before sending it to the back-end. Can you please suggest if this can be done?


The code that we are using is as below:
var dataset = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields : fieldsValueArray,
root: 'rows'
}),
proxy: new Ext.data.HttpProxy({
url : urlLocal
}),
autoLoad : true,
baseParams: {
'optionIndex': optionIndex
}
});


var combobox = new Ext.form.ComboBox({
id: optionId,
hideTrigger : true,
store: dataset,
editable: true,
displayField:display_field_json,
valueField:value_field_json,
typeAhead: false,
mode: 'remote',
triggerAction: 'all',
renderTo: reportId + '_' + optionIndex + '_ControlNugget_Div',
selectOnFocus:true,
value: actualValue,
width:inputWidth,
forceSelection: !disableAutoSuggest,
minLength:minLength,
minLengthText:mandatoryMessage,
mutuallyExclusiveCompIds:mutuallyExclusiveCompIds,
minChars : minChars,
listeners:{
'blur': disableComponent.createDelegate(this, [mutuallyExclusiveCompIds])
}
});


if(!disableAutoSuggest && actualValue != "" && actualValue != undefined && actualValue != null)
{
dataset.load({
params: {
'query': actualValue
},
callback: function(rs) {
var recordIndex = this.find(value_field_json, actualValue);
if(recordIndex != -1){
var displayText = this.getAt(recordIndex).data[display_field_json];
if(displayText != null && displayText != undefined ){
combobox.setRawValue(displayText);
}
}
}
});
}

mitchellsimoens
29 Apr 2013, 5:38 AM
Maybe try to listen to beforeload event on the store to change the param.

abhishek4
30 Apr 2013, 11:20 AM
Thanks a lot, it worked with the beforeLoad Listener.