evoluteur / structured-filter

jQuery UI widget for structured queries like "Contacts where Firstname starts with A and Birthday before 1/1/2000 and State in (CA, NY, FL)"...
http://evoluteur.github.io/structured-filter/
MIT License
258 stars 61 forks source link

Dropdown select filter #12

Open jsmccrumb opened 7 years ago

jsmccrumb commented 7 years ago

It would be nice to give a predefined list of values for a filter. For example, if the data that was being queried only had X options for a field, would be nice to show all of them and let the user select the one they wanted. Would use less screen space than a normal list of say 10 options, though would be limited to only one option?

Perhaps:

{ type: "selectList", id: "myID", label: "Birthmonth", list: [
  {id: "jan", label: "January"},
  {id: "feb", label: "February"},
  {id: "mar", label: "March"},
  {id: "apr", label: "April"},
  {id: "may", label: "May"},
  {id: "jun", label: "June"},
  {id: "jul", label: "July"},
  {id: "aug", label: "August"},
  {id: "sep", label: "September"},
  {id: "oct", label: "October"},
  {id: "nov", label: "November"},
  {id: "dec", label: "December"}
]}

and then:

case fTypes.selectList:
  var arrayLength = this._field.list.length;
  h+='<select id="value">'+EvoUI.optNull;
  for (var i = 0; i < arrayLength; i++) {
    h+=EvoUI.inputOption(this._field.list[i].id, this._field.list[i].label);
  }
  h+='</select>';
  break;

just a rough sketch of a possible way?