Created
January 24, 2017 17:12
-
-
Save adamlwalker/9ffed3b8774ea89d40e9e3eaf5152d2b to your computer and use it in GitHub Desktop.
choice_by_query ExtJS + Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def choice_by_query(name, subj, query, options={}) | |
| res = execute_query(query, {}) | |
| data = (res || []).map{|val| [val['value']]}.sort.uniq.to_json | |
| store = UIUtils.raw_js("new Ext.data.SimpleStore({fields: ['value'], data: #{data}})") | |
| options.merge!(xtype: 'select', clearTrigger: 2, inputValue: true, store: store, queryMode: 'local', pageSize: 0, | |
| displayField: 'value', valueField: 'value', forceSelection: true, selectOnFocus: true) | |
| udf(name, subj, options) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment