Sherzod Posted March 17 Posted March 17 Implements a familiar UX where typing letters moves the selection to the first matching item, similar to Windows Explorer. I thought someone might find this useful... UniListBox.ClientEvents.ExtEvents -> function afterrender(sender, eOpts) { var lb = sender, store = lb.getStore(), field = lb.displayField || 'val'; lb._searchBuffer = ''; lb.on('keypress', function(e){ var ch = e.event.key; if (!ch || ch.length !== 1) return; lb._searchBuffer += ch.toLowerCase(); Ext.defer(function(){ lb._searchBuffer = ''; }, 1000); var idx = store.findBy(function(rec){ var text = rec.get(field); return text && text.toLowerCase().startsWith(lb._searchBuffer); }); if (idx !== -1) { lb.boundList.getSelectionModel().select(idx); lb.boundList.getNavigationModel().setPosition(idx); } }); } 3 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.