From 632a87147b537be65b79007318dc05f484aa5d16 Mon Sep 17 00:00:00 2001 From: mtakhter Date: Thu, 1 Jun 2017 12:29:51 -0400 Subject: [PATCH] Create slick.multiselecteditor.js This plugin is for example-editor-multiselect-dropdown.html --- plugins/slick.multiselecteditor.js | 207 +++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 plugins/slick.multiselecteditor.js diff --git a/plugins/slick.multiselecteditor.js b/plugins/slick.multiselecteditor.js new file mode 100644 index 000000000..5d96d9fee --- /dev/null +++ b/plugins/slick.multiselecteditor.js @@ -0,0 +1,207 @@ +/*** + * Contains basic SlickGrid editors. + * @module Editors + * @namespace Slick + */ + +(function ($) { + // register namespace + $.extend(true, window, { + "Slick": { + "Editors": { + "MultiSelectCheckBox": MultiSelectDropdownEditor + } + } + }); + + /* + * An example of a "Multi-Select Dropdown" editor. + * The UI is added onto document BODY and .position(), .show() and .hide() are implemented. + * KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter. + */ + + function MultiSelectDropdownEditor(args) { + var $input, $wrapper,$checkBoxInput, selectedchkBoxArray=[]; + var defaultValue; + var scope = this; + // check scope get this value + + var chkBoxListData = getChkBoxDataList(args); + var chkBoxAllValues = chkBoxListData.AllValues; + chkBoxAllValues.sort(); + var selectedchkBox = chkBoxListData.SelectedValues; + if(!(selectedchkBox == undefined || selectedchkBox == '')){ + if(selectedchkBox.length>0) selectedchkBoxArray = selectedchkBox.split(";"); + } + this.init = function () { + + if(chkBoxAllValues.length!=0){ + var $container = $("body"); + $wrapper = $("
") + .appendTo($container); + + for (var i = 0; i < chkBoxAllValues.length; i++) { + if(!(selectedchkBoxArray == undefined || selectedchkBoxArray == '')){ + if (selectedchkBoxArray.length>0 && selectedchkBoxArray.indexOf(chkBoxAllValues[i]) > -1){ + $checkBoxInput = $("" + chkBoxAllValues[i] + "
"); + } + else + $checkBoxInput = $("" + chkBoxAllValues[i] + "
"); + } + else + $checkBoxInput = $("" + chkBoxAllValues[i] + "
"); + + $wrapper.append($checkBoxInput); + } + + $wrapper.append("

"); + + $input = $("