apostrophe/data/media/table_editor/handsontable/demo/checkbox.html

202 lines
6.3 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>Checkbox cell type - Handsontable</title>
<!--
Loading Handsontable (full distribution that includes all dependencies)
-->
<link data-jsfiddle="common" rel="stylesheet" media="screen" href="../dist/handsontable.full.css">
<script data-jsfiddle="common" src="../dist/handsontable.full.js"></script>
<!--
Loading demo dependencies. They are used here only to enhance the examples on this page
-->
<link data-jsfiddle="common" rel="stylesheet" media="screen" href="css/samples.css?20140331">
<script src="js/samples.js"></script>
<script src="js/highlight/highlight.pack.js"></script>
<link rel="stylesheet" media="screen" href="js/highlight/styles/github.css">
<link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">
<!--
Facebook open graph. Don't copy this to your project :)
-->
<meta property="og:title" content="Numeric cell type">
<meta property="og:description"
content="Numeric cell type uses Numeral.js as the formatting library.">
<meta property="og:url" content="http://handsontable.com/demo/numeric.html">
<meta property="og:image" content="http://handsontable.com/demo/image/og-image.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="409">
<meta property="og:image:height" content="164">
<link rel="canonical" href="http://handsontable.com/demo/numeric.html">
<!--
Google Analytics for GitHub Page. Don't copy this to your project :)
-->
<script src="js/ga.js"></script>
<script data-jsfiddle="common">
function getCarData() {
return [
{car: "Mercedes A 160", year: 2006, available: true, comesInBlack: 'yes'},
{car: "Citroen C4 Coupe", year: 2008, available: false, comesInBlack: 'yes'},
{car: "Audi A4 Avant", year: 2011, available: true, comesInBlack: 'no'},
{car: "Opel Astra", year: 2004, available: false, comesInBlack: 'yes'},
{car: "BMW 320i Coupe", year: 2011, available: false, comesInBlack: 'no'}
];
}
</script>
</head>
<body>
<div class="wrapper">
<div class="wrapper-row">
<div id="global-menu-clone">
<h1><a href="../index.html">Handsontable</a></h1>
</div>
<div id="container">
<div class="columnLayout">
<div class="rowLayout">
<div class="descLayout">
<div class="pad" data-jsfiddle="example1">
<h2>Checkbox cell type</h2>
<p>If you have cells that contains only 2 possible values, you can use <code>checkbox</code> type.
Data in such cells will be rendered as checkbox
and can be easily changed by checking/unchecking the checkbox. </p>
<p>Checking and unchecking can be performed using mouse or by pressing <kbd>SPACE</kbd>.
You can change the state of multiple cells at once.
Simply select cells you want to change and press <kbd>SPACE</kbd></p>
<div id="example1"></div>
<p>
<button name="dump" data-dump="#example1" data-instance="hot1" title="Prints current data source to Firebug/Chrome Dev Tools">
Dump
data to console
</button>
</p>
</div>
</div>
<div class="codeLayout">
<div class="pad">
<div class="jsFiddle">
<button class="jsFiddleLink" data-runfiddle="example1">Edit in jsFiddle</button>
</div>
<script data-jsfiddle="example1">
var example1 = document.getElementById('example1'),
hot1;
hot1 = new Handsontable(example1, {
data: getCarData(),
startRows: 7,
startCols: 4,
colHeaders: ['Car', 'Year', 'Available'],
colWidths: [120, 50, 60],
columnSorting: true,
columns: [
{
data: 'car'
// 1nd column is simple text, no special options here
},
{
data: 'year',
type: 'numeric'
},
{
data: 'available',
type: 'checkbox'
}
]
});
</script>
</div>
</div>
</div>
<div class="rowLayout">
<div class="descLayout">
<div class="pad" data-jsfiddle="example2">
<a name="lazy"></a>
<h2>Check templates</h2>
<p>If you want use other values than <code>true</code> and <code>false</code>,
you have to provide this information using <code>checkedTemplate</code> and
<code>uncheckedTemplate</code>. Handsontable will then update your data using appropriate template.
</p>
<div id="example2"></div>
<p>
<button name="dump" data-dump="#example2" data-instance="hot2" title="Prints current data source to Firebug/Chrome Dev Tools">
Dump
data to console
</button>
</p>
</div>
</div>
<div class="codeLayout">
<div class="pad">
<div class="jsFiddle">
<button class="jsFiddleLink" data-runfiddle="example2">Edit in jsFiddle</button>
</div>
<script data-jsfiddle="example2">
var example2 = document.getElementById('example2');
var hot2 = new Handsontable(example2,{
data: getCarData(),
startRows: 7,
startCols: 4,
colHeaders: ["Car", "Year", "Comes in black"],
colWidths: [120, 50, 60],
columnSorting: true,
columns: [
{
data: "car"
//1nd column is simple text, no special options here
},
{
data: "year",
type: 'numeric'
},
{
data: "comesInBlack",
type: "checkbox",
checkedTemplate: 'yes',
uncheckedTemplate: 'no'
}
]
});
</script>
</div>
</div>
</div>
<div class="footer-text">
</div>
</div>
</div>
</div>
</div>
<div id="outside-links-wrapper"></div>
</body>
</html>