Multicolumn with checkboxes

Multicolumn combo with checkboxes demo

* Any resemblance to reality is purely coincidental

Init from script


JSON from server


XML from server


Custom checkbox

</> Source
<!DOCTYPE html>
<html>
<head>
	<title>Multicolumn with checkboxes</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<style>
		h4.info_text {
			font-family: Arial;
			font-size: 14px;
		}
		td.descr_td {
			 padding-right: 50px;
			 vertical-align: top;
		}
		/* custom cehckbox css */
		/* copy css from chanekbox, change style name and bg-image */
		div.dhxcombolist_material div.dhxcombo_option div.dhxcombo_checkbox.my_css_1 {
			background-image: url("../common/flags2/flag_blue.png");
			background-position: center center;
		}
		div.dhxcombolist_material div.dhxcombo_option div.dhxcombo_checkbox.my_css_0 {
			background-image: url("../common/flags2/flag_gray.png");
			background-position: center center;
		}
		/* make default checkbox margin smalle to fill to a cell */
		div.dhxcombolist_material div.dhxcombo_option div.dhxcombo_image,
		div.dhxcombolist_material div.dhxcombo_option div.dhxcombo_checkbox {
			margin: 0px 2px;
		}
	</style>
	<script>
		var myCombo;
		var myCombo2;
		var myCombo3;
		var myCombo4;
		
		function doOnLoad() {
			
			// from script
			myCombo = new dhtmlXCombo("combo_zone_script", "combo_script", 200, "checkbox"); // make sure you set 4th param to "checkbox"
			myCombo.setTemplate({
				input: "#capital#, #country#",
				columns: [
					{header: "&nbsp;",  width:  41, 		option: "#checkbox#"}, // column for checkboxes
					{header: "&nbsp;",  width:  40, css: "flag",    option: "<img src='#flag#' border='0' style='margin-top: 8px; margin-left: 2px;'>"},
					{header: "Capital", width:  80, css: "capital", option: "#capital#"},
					{header: "Country", width: 110, css: "country", option: "#country#"},
					{header: "Proverb", width: 250, css: "proverb", option: "#proverb#"}
				]
			});
			myCombo.addOption([
				{value: "1", text: { flag: "../common/flags/austria.png", country: "Austria", capital: "Vienna", proverb: "Two wrongs don't make a right" }, checked: 1 },
				{value: "2", text: { flag: "../common/flags/belarus.png", country: "Belarus", capital: "Minsk", proverb: "The pen is mightier than the sword" } },
				{value: "3", text: { flag: "../common/flags/cameroon.png", country: "Cameroon", capital: "Yaoundé", proverb: "Actions speak louder than words" }, checked: 1, selected: 1 },
				{value: "4", text: { flag: "../common/flags/canada.png", country: "Canada", capital: "Ottawa", proverb: "If it ain't broke, don't fix it" } }
			]);
			myCombo.enableFilteringMode(true);
			
			// fron json
			myCombo2 = new dhtmlXCombo("combo_zone_json", "combo_json", 200, "checkbox");
			myCombo2.load("../common/multicolumn_data_checkbox.json");
			myCombo2.enableFilteringMode(true);
			
			// from xml
			myCombo3 = new dhtmlXCombo("combo_zone_xml", "combo_xml", 200, "checkbox");
			myCombo3.load("../common/multicolumn_data_checkbox.xml");
			myCombo3.enableFilteringMode(true);
			
			// custom checkbox
			myCombo4 = new dhtmlXCombo("combo_zone_custom", "combo_custom", 200, "my_checkbox");
			myCombo4.load("../common/multicolumn_data_checkbox.json");
			myCombo4.enableFilteringMode(true);
		}
		
		// you can just change images, but here we will show how to create custom item based on checkbox,
		// then you will able to use both checkboxes and custom checkboxes together on same page
		// most functionality will inherited from default checkbox item
		dhtmlXCombo.prototype.modes.my_checkbox = {
			// just change css pref a bit, all other code will correct
			// #state# will replaced with "1" for checked and "0" for not checked
			image_css: "dhxcombo_checkbox my_css_#state#",
			// also you can disable top level image, which used just for ui offset,
			// no needs to have this offset in multicolumn combo
			image: false
		};
		
		// copy other code from default checkbox
		dhtmlXComboExtend("my_checkbox", "checkbox");
		
		// setChecked/getChecked already exist, no more actions
		
		
	</script>
</head>
<body onload="doOnLoad();">
	<h3>Multicolumn combo with checkboxes demo</h3>
	<div style='font-size: 10px; color: #555; font-family: Arial;'><b>*</b> Any resemblance to reality is purely coincidental</div>
	<br>
	<h4 class="info_text">Init from script</h3>
	<div id="combo_zone_script"></div>
	<br>
	<h4 class="info_text">JSON from server</h3>
	<div id="combo_zone_json"></div>
	<br>
	<h4 class="info_text">XML from server</h3>
	<div id="combo_zone_xml"></div>
	<br>
	<h4 class="info_text">Custom checkbox</h3>
	<div id="combo_zone_custom"></div>
</body>
</html>

Documentation

Check documentation to learn how to use the components and easily implement them in your applications.