Jun 06, 2011, 3:27 PM
[CLOSED] Combo Box Pre-Selection Problem
Hi
I have tried to develop a drop down list that pre-selects a value in the Example
https://examples1.ext.net/#/Form/Com...Custom_Search/
I have added the script:
1) If you type too slow, it pre-selects "cowslip" again, and you end up typing in the middle of the word cowslip.
2) If you search for something that isnt in the store, it clears what you have typed in.
3) If you search for something that is in the store, eg *, it replaces what you searched for with "cowslip". Even though the list search correctly and you selected an item in it.
Hope you can help, this is driving me bonkers! :)
Ian
I have tried to develop a drop down list that pre-selects a value in the Example
https://examples1.ext.net/#/Form/Com...Custom_Search/
I have added the script:
<script type="text/javascript">
function afterRender(e)
{
var val = "cowslip";
e.store.baseParams = { preSelect: val };
var store = e.getStore();
store.on("load", function ()
{
e.setValue(val);
if (e.store.data.length == 0)
{
e.clearValue();
}
});
store.load();
clensePreSelect(e);
}
function clensePreSelect(selector)
{
selector.store.baseParams = { preSelect: null };
selector.store.removeAll(true);
selector.store.clearData();
selector.setValue(null);
selector.clearValue();
selector.setRawValue(null);
selector.lastQuery = null;
selector.store.totalLength = 0;
}
function checkValue(selector)
{
clensePreSelect(selector);
}
</script>
Adding this markup to the combobox item itself: <Triggers>
<%--<ext:FieldTrigger Icon="SimpleWrench" Qtip="Check value" />--%>
<ext:FieldTrigger Icon="Clear" Qtip="Clear" />
</Triggers>
<Listeners>
<AfterRender Handler="afterRender(this);" />
<TriggerClick Handler="checkValue(this);" />
</Listeners>
However, when it loads it successfully selects "cowslip", but if you hit clear and then perform another search:1) If you type too slow, it pre-selects "cowslip" again, and you end up typing in the middle of the word cowslip.
2) If you search for something that isnt in the store, it clears what you have typed in.
3) If you search for something that is in the store, eg *, it replaces what you searched for with "cowslip". Even though the list search correctly and you selected an item in it.
Hope you can help, this is driving me bonkers! :)
Ian
Last edited by Daniil; Jun 13, 2011 at 3:52 PM.
Reason: [CLOSED]