I'm using a custom theme that extends the Neptune theme and I've written my own MyApp.ux.form.SearchField class based on the Custom Form Field example.
I can't figure out how to make the magnifying glass icon show up in the field like the example. I'm pretty sure I need to somehow tell my theme (or maybe even the base Neptune theme) about the new CSS classes that are required (x-form-clear-trigger and x-form-search-trigger) but I can't find any documentation that shows the required steps.
How to use UX SearchField?
Here's my code:
Code:
Ext.define("MyApp.ux.form.SearchField", {
extend: "Ext.form.field.Trigger",
xtype: "myapp-searchfield",
trigger1Cls: Ext.baseCSSPrefix + "form-clear-trigger",
trigger2Cls: Ext.baseCSSPrefix + "form-search-trigger",
hasSearch : false,
paramName : "query",
initComponent: function() {
var me = this;
me.callParent(arguments);
me.on("specialkey", function(f, e){
if (e.getKey() == e.ENTER) {
me.onTrigger2Click();
}
});
},
afterRender: function(){
this.callParent();
this.triggerCell.item(0).setDisplayed(false);
},
onTrigger1Click : function(){
var me = this;
if (me.hasSearch) {
me.setValue("");
me.store.clearFilter();
me.hasSearch = false;
me.triggerCell.item(0).setDisplayed(false);
me.updateLayout();
}
},
onTrigger2Click : function(){
var me = this,
value = me.getValue();
if (value.length > 0) {
// Param name is ignored here since we use custom encoding in the proxy.
// id is used by the Store to replace any previous filter
me.store.filter({
id: me.paramName,
property: me.paramName,
value: value
});
me.hasSearch = true;
me.triggerCell.item(0).setDisplayed(true);
me.updateLayout();
}
}
});
I can't figure out how to make the magnifying glass icon show up in the field like the example. I'm pretty sure I need to somehow tell my theme (or maybe even the base Neptune theme) about the new CSS classes that are required (x-form-clear-trigger and x-form-search-trigger) but I can't find any documentation that shows the required steps.
How to use UX SearchField?
Aucun commentaire:
Enregistrer un commentaire