jquery - visualsearch (faceted query search) using Sencha ExtJS 5 -


i've been trying implemented faceted search autocomplete using sencha extjs 5. similar "visualsearch" plugin developed using jquery.

this i'd do:

http://jsfiddle.net/tuping/7wyhx/1/

so far, have:

ext.define('app.custom.searcherwidget', { extend: 'ext.form.field.combobox', alias: 'widget.searcher', emptytext: 'select entity',  iskeyselected: false,  currselectedkey: null,  facetedquery: null,  initcomponent: function() {     var me = this;     me.store = me.retrievekeys();//todo: changed     me.querymode = 'local';     me.displayfield = 'description';     me.valuefield = 'code';     me.typeahead = true;     me.minchars = 1;     me.enablekeyevents = true;     me.triggeraction = 'query';     me.hidetrigger = true;      me.on({         change: me.fixchange,         beforeselect: me.fixbeforeselect,         beforequery: me.fixbeforequery,         keypress: me.checkkeypressed,         scope: me     });      me.callparent(arguments); },  checkkeypressed: function(combo, e, eopts) {     var me = this,         selectedvalue = combo.getvalue(),         combostore = combo.store;      if (selectedvalue && selectedvalue.length > 0) {         //not first time, check if key or value         if (this.iskeyselected) {             //is key             combostore.loaddata(me.retrievekeys());         } else {             //is value , key current selected             combostore.loaddata(me.retrievevaluesbasedonkeys(me.currselectedkey));         }         combostore.load();     } else {         //it empty, should check key         combostore.loaddata(me.retrievekeys());         combostore.load();     }  },  fixchange: function(combo, newval, oldval, eopts) {     var selectedvalue = combo.getvalue();      if (!(selectedvalue && selectedvalue.length > 0)) {         combo.collapse();     } else {      }  },  fixbeforeselect: function(combo, record, index, eopts) {     var me = this,         selectedvalue = combo.getvalue(),         terms = selectedvalue.split( /,\s*/ );      if (record && record.get('type') === 'key') {         iskeyselected = true;         me.currselectedkey = record.get('description');         terms.pop();         terms.push(me.currselectedkey);         terms.push('');         combo.setvalue(terms.join( ': ' ));         combo.collapse();     } else { //          terms.pop(); //          terms.push(record.get('description')); //          terms.push(''); //          combo.setvalue(terms.join( ', ' )); //          combo.collapse();     }      return false; },  fixbeforequery: function(queryplan, eopts) {      var terms = queryplan.query.split( /,\s*/ );      queryplan.query = terms[terms.length - 1];      return (queryplan.query && queryplan.query.length > 0); },  retrievekeys: function() {     return ext.create('ext.data.arraystore', {         fields: [{name: 'code'},                  {name: 'description'},                  {name: 'type'}],         data: [                [1, 'domain', 'key'],                [2, 'instance', 'key'],                [3, 'attribute', 'key'],                [4, 'relation', 'key']         ]     }); },  retrievevaluesbasedonkeys: function(key) {     var me = this,         rawdata = me.retrievemockvalues(),         databasedonkey = [];      (var = 0; < rawdata.length; i++) {         var currelement = rawdata[i];         if (currelement.type === key) {             databasedonkey.push(currelement);         }     }      return ext.create('ext.data.arraystore', {         fields: [{name: 'code'},                  {name: 'description'},                  {name: 'type'}],         data: databasedonkey     }); },  retrievemockvalues: function() {     return [{'code': 1, 'description': 'verizon', 'type': 'domain'},             {'code': 2, 'description': 'terremark', 'type': 'domain'},             {'code': 3, 'description': 'sencha', 'type': 'domain'},             {'code': 4, 'description': 'microsoft', 'type': 'domain'},             {'code': 5, 'description': 'oracle', 'type': 'domain'},             {'code': 6, 'description': 'dev1', 'type': 'instance'},             {'code': 7, 'description': 'dev2', 'type': 'instance'},             {'code': 8, 'description': 'dev3', 'type': 'instance'},             {'code': 9, 'description': 'dev4', 'type': 'instance'},             {'code': 10, 'description': 'dev5', 'type': 'instance'},             {'code': 11, 'description': 'dev6', 'type': 'instance'},             {'code': 12, 'description': 'dev7', 'type': 'instance'},             {'code': 13, 'description': 'dev8', 'type': 'instance'},             {'code': 14, 'description': 'red', 'type': 'attribute'},             {'code': 15, 'description': 'white', 'type': 'attribute'},             {'code': 16, 'description': 'black', 'type': 'attribute'},             {'code': 17, 'description': 'blue', 'type': 'attribute'},             {'code': 18, 'description': 'one-to-many', 'type': 'relation'},             {'code': 19, 'description': 'many-to-many', 'type': 'relation'},             {'code': 20, 'description': 'one-to-one', 'type': 'relation'}             ]; },  retrieveentities: function() {     return ext.create('ext.data.arraystore', {         fields: [           {name: 'code'},           {name: 'type'},           {name: 'description'}         ],         data  : [           [1,'domain','at&t'],           [2,'domain','altria group inc'],           [3,'domain','american express company'],           [4,'domain','bellcorp'],           [5,'domain','claro'],           [6,'domain','dell'],           [7,'domain','e&e'],           [8,'domain','farenheit'],           [9,'domain','garman'],           [10,'domain','hell'],           [11,'domain','intel'],           [12,'domain','jasper'],           [13,'domain','halmington'],           [14,'domain','lll corp'],           [15,'domain','verizon'],           [5,'instance','american express company']         ]       }); }  }); 

i tried adapt "visualsearch" of jquery extjs code... no success @ all... wonder if give me clue or hand on this.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -