123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /*
- * Copyright Scand LLC http://www.scbr.com To use this component please contact
- * info@scbr.com to obtain license
- */
- /*
- * Textfield with Button eXcell v.1.0 for dhtmlxGrid (c)Scand LLC 2005
- *
- *
- * The corresponding cell value in XML should be
- *
- * Samples:
- *
- */
- function eXcell_wbut(cell) {
- this.cell = cell;
- this.grid = this.cell.parentNode.grid;
- this.edit = function() {
- var val = this.getValue().toString();
- var valAr = val.toString().split("^");
- this.obj = document.createElement("INPUT");
- this.obj.style.width = "60px";
- this.obj.style.height = (this.cell.offsetHeight - (this.grid.multiLine
- ? 5
- : 4))
- + "px";
- this.obj.style.border = "0px";
- this.obj.style.margin = "0px";
- this.obj.style.padding = "0px";
- this.obj.style.overflow = "hidden";
- this.obj.style.fontSize = _isKHTML ? "10px" : "12px";
- this.obj.style.fontFamily = "Arial";
- this.obj.wrap = "soft";
- this.obj.style.textAlign = this.cell.align;
- this.obj.onclick = function(e) {
- (e || event).cancelBubble = true
- }
- this.cell.innerHTML = "";
- this.cell.appendChild(this.obj);
- this.obj.onselectstart = function(e) {
- if (!e)
- e = event;
- e.cancelBubble = true;
- return true;
- };
- this.obj.style.textAlign = this.cell.align;
- this.obj.value = valAr[0]
- this.obj.focus()
- this.obj.focus()
- this.cell.appendChild(document.createTextNode(" ")); // Create space
- // between text
- // box and
- // button
- var butElem = document.createElement('input'); // This is the button
- // DOM code
- if (isIE()) {
- butElem.style.height = (this.cell.offsetHeight - (this.grid.multiLine
- ? 5
- : 4))
- + "px";
- butElem.style.lineHeight = "5px";
- } else {
- butElem.style.fontSize = "8px";
- butElem.style.width = "10px";
- butElem.style.marginTop = "-5px"
- }
- butElem.type = 'button'
- butElem.name = 'Lookup'
- butElem.value = '...'
- var inObjValue = this.obj.value;
- var inCellIndex = this.cell.cellIndex
- var inRowId = this.cell.parentNode.idd
- var inGrid = this.grid
- var inCell = this;
- butElem.onclick = function(evt) {
- if (valAr.length > 1) {
- eval(valAr[1] + "(inGrid,'" + inObjValue + "','" + inRowId
- + "'," + inCellIndex + ")");
- }
- }
- this.cell.appendChild(butElem);
- }
- this.getValue = function() {
- var outAr = new Array();
- outAr[0] = this.cell.innerHTML;
- if (this.cell.funcToCall) {
- outAr[1] = this.cell.funcToCall
- }
- return outAr.join("^")
- }
- this.setValue = function(val) {
- alert(this.obj)
- if (this.obj) {
- alert(this.obj.value + "::" + val)
- this.obj.value = val;
- }
- var valAr = val.split("^");
- this.cell.innerHTML = valAr[0];
- if (valAr.length > 1) {
- this.cell.funcToCall = valAr[1]
- }
- }
- this.detach = function() {
- alert(this.obj.value)
- this.setValue(this.obj.value);
- return this.val != this.getValue();
- }
- }
- eXcell_wbut.prototype = new eXcell;
|