Created
February 8, 2016 19:22
-
-
Save odoe/fe65f907c6d59b65c418 to your computer and use it in GitHub Desktop.
This file contains 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
define([ | |
'dojo/_base/declare', | |
'dijit/_WidgetBase', | |
'dijit/_TemplatedMixin', | |
'dojo/text!./templates/Widget.html' | |
], function( | |
declare, | |
_WidgetBase, _TemplatedMixin, | |
templateString | |
) { | |
function val(e) { | |
return e.target.value; | |
} | |
var Widget = _WidgetBase.createSubclass(_TemplatedMixin, { | |
templateString: templateString, | |
placeholder: 'Search camera id', | |
baseClass: 'camsearch', | |
onChange: function(e) { | |
var value = val(e); | |
var store = this.store; | |
store.map(function(x) { | |
x.visible = false; | |
return x; | |
}).filter(function(x) { | |
return x.CameraID === Number(value); | |
}).map(function(x) { | |
x.visible = true; | |
store.removeItem(x); | |
store.addItem(x); | |
}); | |
}, | |
onRefresh: function() { | |
this.inputNode.value = ''; | |
var store = this.store; | |
store.map(function(x) { | |
x.visible = true; | |
return x; | |
}).filter(function(x) { | |
// trick to force a collection change event | |
return x.CameraID === Math.floor(Math.random() * 100) + 1000; | |
}).map(function(x) { | |
// this will trigger a Collection "change" event | |
store.removeItem(x); | |
store.addItem(x); | |
}); | |
} | |
}); | |
return Widget; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment