EasyUI Forum
May 09, 2024, 03:35:59 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: Customize Radio and Checkbox Controls  (Read 7892 times)
bdearborn
Newbie
*
Posts: 19


View Profile
« on: December 14, 2015, 07:08:37 PM »

Can custom control rendering be setup to make radio and checkbox controls look nice like in bootstrap?

http://getbootstrap.com/javascript/#buttons-checkbox-radio
Logged
bdearborn
Newbie
*
Posts: 19


View Profile
« Reply #1 on: December 14, 2015, 07:09:29 PM »

JeasyUI support response:

The linkbutton components can act as radio and check buttons. Please refer to:

http://jsfiddle.net/yeyfccov/
Logged
bdearborn
Newbie
*
Posts: 19


View Profile
« Reply #2 on: December 14, 2015, 07:14:08 PM »

Is there a way to bind the buttons to an input on a form? Also, it would be great if there were options to get/set items similar to a combo.

getValues
setValues
getValue
setValue
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 15, 2015, 12:38:48 AM »

A function 'makeButtonGroup' can be used to build the linkbutton groups in more easier way. This function will build a hidden <input> element that will be post to the server.
Code:
function makeButtonGroup(c, options){
    var input = $('<input type="hidden">').attr('name', options.name).insertAfter(c.children('a:first'));
    $(c).addClass('m-buttongroup');
    $(c).children('a').linkbutton($.extend({}, options, {
        toggle: true,
        onClick: function(){
            if (options.group){
                input.val($(this).attr('value'));
            } else {
                var vv = [];
                $(c).children('a').each(function(){
                    if ($(this).linkbutton('options').selected){
                        vv.push($(this).attr('value'));
                    }
                });
                input.val(vv.join(','));
            }
        }
    }));
}

Before calling this function, prepare the group elements.
Code:
<span id="rr">
    <a href="#" value="m">Modem</a>
    <a href="#" value="s">Scanner</a>
    <a href="#" value="t">Tablet</a>
</span>
<span id="cc">
    <a href="#" value="m">Modem</a>
    <a href="#" value="s">Scanner</a>
    <a href="#" value="t">Tablet</a>
</span>

Calling 'makeButtonGroup' function with 'group' property will build the radio buttons, otherwise build the check buttons.
Code:
makeButtonGroup($('#rr'), {
    name: 'n1',
    group: 'g2'
})
makeButtonGroup($('#cc'), {
    name: 'n2'
})
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!