\Kendo\UI\SwitchButton

A PHP wrapper for Kendo UI Switch.

Inherits from \Kendo\UI\Widget.

Usage

To use SwitchButton in a PHP page instantiate a new instance, configure it via the available configuration methods and output it by echo-ing the result of the render method.

Using Kendo SwitchButton

<?php
// Create a new instance of SwitchButton and specify its id
$switch = new \Kendo\UI\SwitchButton('Switch');

// Configure it
$switch->checked(true)

// Output it

echo $switch->render();
?>

Methods

change

Fires when the checked state of the Kendo UI Switch changes by user interaction. For additional information check the change event documentation.

Returns

\Kendo\UI\SwitchButton

Parameters

$value string|\Kendo\JavaScriptFunction

Example - using string which defines a JavaScript function

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change('function(e) { }');
?>

Example - using string which defines a JavaScript name

<script>
    function onChange(e) {
        // handle the change event.
    }
</script>
<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change('onChange');
?>

Example - using \Kendo\JavaScriptFunction

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->change(new \Kendo\JavaScriptFunction('function(e) { }'));
?>

checked

The checked state of the widget.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->checked(true);
?>

enabled

If set to false the widget will be disabled and will not allow the user to change its checked state.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->enabled(true);
?>

messages

Defines the text of the checked and unchecked labels that are shown within the Switch. All labels could be localized.

Returns

\Kendo\UI\SwitchButton

Parameters

$value \Kendo\UI\SwitchButtonMessages|array

Example - using \Kendo\UI\SwitchButtonMessages

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$messages = new \Kendo\UI\SwitchButtonMessages();
$checked = 'value';
$messages->checked($checked);
$switch->messages($messages);
?>

Example - using array

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$checked = 'value';
$switch->messages(array('checked' => $checked));
?>

readonly

If set to true the Kendo UI Switch will render into its read-only state.

Returns

\Kendo\UI\SwitchButton

Parameters

$value boolean

Example

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->readonly(true);
?>

width

The width of the Kendo UI Switch.

Returns

\Kendo\UI\SwitchButton

Parameters

$value float|string

Example - using float

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->width(1);
?>

Example - using string

<?php
$switch = new \Kendo\UI\SwitchButton('Switch');
$switch->width('value');
?>
In this article
Not finding the help you need?