EasyUI Forum
December 20, 2025, 04:50:14 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to use switchbutton in PropertyGrid?  (Read 10422 times)
huyannet
Newbie
*
Posts: 6


View Profile Email
« on: June 16, 2016, 01:37:19 AM »

I use only two value properties as 'true' & 'false'. How to do that?
My code:
rows = [
   {field:"a",name:"jeasyui",value:"true",group:"Libraries", editor:{
        type:"switchbutton", options: {
               valueField: "value",
               textField: "label",
               editable: false,
               data: test
            }
        }
        },

][/font]
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 16, 2016, 06:28:48 PM »

You have to extend the 'switchbutton' editor before using it.
Code:
<script>
$.extend($.fn.datagrid.defaults.editors, {
switchbutton:{
init:function(container,options){
var input = $('<input type="text" class="datagrid-editable-input">').appendTo(container);
return input.switchbutton(options);
},
getValue:function(target){
return $(target).switchbutton('options').checked;
},
setValue:function(target,value){
if (value){
$(target).switchbutton('check');
} else {
$(target).switchbutton('uncheck');
}
},
resize: function(target, width){
$(target).switchbutton('resize', {width:width});
}
}
});
</script>

Usage example:
Code:
{"name":"FrequentBuyer","value":false,"group":"Marketing Settings","editor":{
"type":"switchbutton",
"options":{
}
}}
Logged
huyannet
Newbie
*
Posts: 6


View Profile Email
« Reply #2 on: June 20, 2016, 12:41:06 AM »

I change $.fn.datagrid.defaults.editors to $.fn.propertygrid.defaults.editors and it work perfect !!
Thanks for the support !
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!