1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /*
- * Copyright Scand LLC http://www.scbr.com To use this component please contact
- * info@scbr.com to obtain license
- */
- // simple text editor
- function eXcell_clist(cell) {
- try {
- this.cell = cell;
- this.grid = this.cell.parentNode.grid;
- } catch (er) {
- }
- this.edit = function() {
- this.val = this.getValue();
- var a = this.grid.clists[this.cell._cellIndex];
- if (!a) {
- return;
- }
- this.obj = document.createElement("DIV");
- var b = this.val.split(",");
- var text = "";
- for (var i = 0; i < a.length; i++) {
- var fl = false;
- for (var j = 0; j < b.length; j++) {
- if (a[i] == b[j]) {
- fl = true;
- }
- }
- if (fl) {
- text += "<div><input type='checkbox' checked='true' /><label>"
- + a[i] + "</label></div>";
- } else {
- text += "<div><input type='checkbox' id='ch_lst_" + i
- + "'/><label>" + a[i] + "</label></div>";
- }
- }
- text += "<div><input type='button' value='Apply' style='width:100px; font-size:8pt;' onclick='this.parentNode.parentNode.editor.detach();'/></div>";
- this.obj.editor = this;
- this.obj.innerHTML = text;
- document.body.appendChild(this.obj);
- this.obj.style.position = "absolute";
- this.obj.style.zIndex = 19;
- this.obj.style.backgroundColor = "white";
- this.obj.style.border = "1px solid black";
- this.obj.style.padding = "2px 2px 2px 2px";
- var arPos = this.grid.getPosition(this.cell);
- this.obj.style.left = arPos[0] - this.grid.objBox.scrollLeft + "px";
- this.obj.style.top = arPos[1] + this.cell.offsetHeight
- - this.grid.objBox.scrollTop + "px";
- this.obj.getValue = function() {
- var text = "";
- for (var i = 0; i < this.childNodes.length - 1; i++) {
- if (this.childNodes[i].childNodes[0].checked) {
- if (text) {
- text += ",";
- }
- text += this.childNodes[i].childNodes[1].innerHTML;
- }
- }
- return text;
- };
- };
- this.getValue = function() {
- // this.grid.editStop();
- return this.cell.innerHTML.toString()._dhx_trim();
- };
- /**
- * @desc: return value to cell, closes editor
- * @returns: if cell's value was changed (true) or not
- * @type: private
- */
- this.detach = function(val) {
- if (this.obj) {
- this.setValue(this.obj.getValue());
- this.obj.editor = null;
- this.obj.parentNode.removeChild(this.obj);
- this.obj = null;
- }
- return this.val != this.getValue();
- };
- }
- eXcell_clist.prototype = new eXcell;
- /**
- * @desc: register list of values for CList cell
- * @param: col - index of CList collumn
- * @param: list - array of list data
- * @type: public
- * @edition: Professional
- */
- dhtmlXGridObject.prototype.registerCList = function(col, list) {
- if (!this.clists) {
- this.clists = new Array();
- }
- this.clists[col] = list;
- };
|