PDA

View Full Version : Custom Boolean Toggle for Editor Grid



Javiera
12 Mar 2008, 11:54 PM
Anyone interested in an iphone-style toggle? Perhaps for editor /property grids? I think it would be a neat alternative to a check or combo box. Thoughts?



<html><head>
<script type="text/javascript">
Ext.onReady(function(){
var toggle = 'off';
var tpl = {
on: new Ext.Template('<img src="btn_on.jpg">'),
off: new Ext.Template('<img src="btn_off.jpg">')
};
Ext.get("btn").on('click', function() {
tpl[toggle].overwrite('btn');
toggle = (toggle == 'on') ? 'off' : 'on';
});
});
</script>
</head>
<body>
<a id="btn"><img src="btn_off.jpg"></a>
</body>
</html>

Condor
13 Mar 2008, 12:43 AM
You could modify the CSS for Ext.grid.CheckColumn and Ext.ux.form.Combobox (http://extjs.com/forum/showthread.php?t=28096) to use these images.

ps. The images are a bit large. They won't fit nicely into the Ext JS theme.