Skip to content

Instantly share code, notes, and snippets.

@adamlwalker
Created January 24, 2017 17:12
Show Gist options
  • Select an option

  • Save adamlwalker/9ffed3b8774ea89d40e9e3eaf5152d2b to your computer and use it in GitHub Desktop.

Select an option

Save adamlwalker/9ffed3b8774ea89d40e9e3eaf5152d2b to your computer and use it in GitHub Desktop.
choice_by_query ExtJS + Rails
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