Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create example-editor-multiselect-dropdown.html #1160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions examples/example-editor-multiselect-dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SlickGrid Example- Multiselect Dropdown Editor</title>
<link rel="stylesheet" href="../slick.grid.css" type="text/css"/>
<link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.24.custom.css" type="text/css"/>
<link rel="stylesheet" href="examples.css" type="text/css"/>
<style>
.cell-title {
font-weight: bold;
}

.cell-effort-driven {
text-align: center;
}
</style>
</head>
<body>
<div style="position:relative">
<div style="width:600px;">
<div id="myGrid" style="width:100%;height:500px;"></div>
</div>

<div class="options-panel">
<h2>Demonstrates:</h2>
<ul>
<li>multi-select dropdown editor control</li>
</ul>

<h2>View Source:</h2>
<ul>
<li><A href="https://github.com/mtakhter/SlickGrid/blob/master/examples/example-editor-multiselect-dropdown.html"
target="_sourcewindow"> View the source for this example on Github</a></li>
</ul>
</div>
</div>

<script src="../lib/firebugx.js"></script>
<!--<script src="../lib/jquery-1.7.min.js"></script>-->
<script src="../lib/jquery-1.11.2.min.js"></script>
<script src="../lib/jquery-ui-1.8.24.custom.min.js"></script>
<script src="../lib/jquery.event.drag-2.2.js"></script>
<script src="../slick.core.js"></script>
<script src="../plugins/slick.cellrangedecorator.js"></script>
<script src="../plugins/slick.cellrangeselector.js"></script>
<script src="../plugins/slick.cellselectionmodel.js"></script>
<script src="../slick.formatters.js"></script>
<script src="../slick.editors.js"></script>
<script src="../slick.grid.js"></script>
<script src="../plugins/slick.multiselecteditor.js"></script>

<script>
function requiredFieldValidator(value) {
if (value == null || value == undefined || !value.length) {
return {valid: false, msg: "This is a required field"};
} else {
return {valid: true, msg: null};
}
}

var grid;
var data = [];
var columns = [
{id: "title", name: "Title", field: "title", width: 150, cssClass: "cell-title"},
{id: "country", name: "Country", field: "country", width: 150, editor: Slick.Editors.MultiSelectCheckBox },
{id: "language", name: "Language", field: "language", width: 130},
{id: "area", name: "Area", field: "area", width: 150}
];
var options = {
editable: true,
enableAddRow: true,
enableCellNavigation: true,
asyncEditorLoading: false,
autoEdit: false
};

$(function () {
for (var i = 0; i < 50; i++) {
var d = (data[i] = {});

d["title"] = "Country " + i;
d["country"] = 'United States;India';
d["language"] = "English";
d["area"] = "123456789 sq Km";

}

grid = new Slick.Grid("#myGrid", data, columns, options);

grid.setSelectionModel(new Slick.CellSelectionModel());

grid.onAddNewRow.subscribe(function (e, args) {
var item = args.item;
grid.invalidateRow(data.length);
data.push(item);
grid.updateRowCount();
grid.render();
});
})

/*
* An example of a "Multi-Select Dropdown" editor.
* "DropdownListData" is an array to store all the checkbox options required for the dropdowwn multi-select field.
*/
var DropdownListData =["Afghanistan","Bangladesh","Canada","China","England","India","Japan","United Kingdom","United States","France"];
function getChkBoxDataList(args) {
var countryLeadsData = [];
// here 'country' is column id
if (args.column.id == 'country') {
var countryData =
{
"AllValues": DropdownListData,
"SelectedValues": args.item.country
/*
* args.item.country is used to read the value of the field "country" of a particular row.
* This "SelectedValues" array generates prepopulated data if you want to retrieve data from your data base.
* Lets for emxample for row no 1 : you have 2 countries, this field captures the name of these countries(should be seprated by semicolon) and mark the checkboxes of those country as checked.
*/
}
return countryData;
}

/*
* add else if conditions if you have another multi-select dropdown list as well.
*/

}
</script>
</body>
</html>