fc8af1eec4bfedb7f11775ae406fdd69cdf0286b.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright Scand LLC http://www.scbr.com To use this component please contact
  3. * info@scbr.com to obtain license
  4. */
  5. /*
  6. * Textfield with Button eXcell v.1.0 for dhtmlxGrid (c)Scand LLC 2005
  7. *
  8. *
  9. * The corresponding cell value in XML should be
  10. *
  11. * Samples:
  12. *
  13. */
  14. function eXcell_wbut(cell) {
  15. this.cell = cell;
  16. this.grid = this.cell.parentNode.grid;
  17. this.edit = function() {
  18. var val = this.getValue().toString();
  19. var valAr = val.toString().split("^");
  20. this.obj = document.createElement("INPUT");
  21. this.obj.style.width = "60px";
  22. this.obj.style.height = (this.cell.offsetHeight - (this.grid.multiLine
  23. ? 5
  24. : 4))
  25. + "px";
  26. this.obj.style.border = "0px";
  27. this.obj.style.margin = "0px";
  28. this.obj.style.padding = "0px";
  29. this.obj.style.overflow = "hidden";
  30. this.obj.style.fontSize = _isKHTML ? "10px" : "12px";
  31. this.obj.style.fontFamily = "Arial";
  32. this.obj.wrap = "soft";
  33. this.obj.style.textAlign = this.cell.align;
  34. this.obj.onclick = function(e) {
  35. (e || event).cancelBubble = true
  36. }
  37. this.cell.innerHTML = "";
  38. this.cell.appendChild(this.obj);
  39. this.obj.onselectstart = function(e) {
  40. if (!e)
  41. e = event;
  42. e.cancelBubble = true;
  43. return true;
  44. };
  45. this.obj.style.textAlign = this.cell.align;
  46. this.obj.value = valAr[0]
  47. this.obj.focus()
  48. this.obj.focus()
  49. this.cell.appendChild(document.createTextNode(" ")); // Create space
  50. // between text
  51. // box and
  52. // button
  53. var butElem = document.createElement('input'); // This is the button
  54. // DOM code
  55. if (isIE()) {
  56. butElem.style.height = (this.cell.offsetHeight - (this.grid.multiLine
  57. ? 5
  58. : 4))
  59. + "px";
  60. butElem.style.lineHeight = "5px";
  61. } else {
  62. butElem.style.fontSize = "8px";
  63. butElem.style.width = "10px";
  64. butElem.style.marginTop = "-5px"
  65. }
  66. butElem.type = 'button'
  67. butElem.name = 'Lookup'
  68. butElem.value = '...'
  69. var inObjValue = this.obj.value;
  70. var inCellIndex = this.cell.cellIndex
  71. var inRowId = this.cell.parentNode.idd
  72. var inGrid = this.grid
  73. var inCell = this;
  74. butElem.onclick = function(evt) {
  75. if (valAr.length > 1) {
  76. eval(valAr[1] + "(inGrid,'" + inObjValue + "','" + inRowId
  77. + "'," + inCellIndex + ")");
  78. }
  79. }
  80. this.cell.appendChild(butElem);
  81. }
  82. this.getValue = function() {
  83. var outAr = new Array();
  84. outAr[0] = this.cell.innerHTML;
  85. if (this.cell.funcToCall) {
  86. outAr[1] = this.cell.funcToCall
  87. }
  88. return outAr.join("^")
  89. }
  90. this.setValue = function(val) {
  91. alert(this.obj)
  92. if (this.obj) {
  93. alert(this.obj.value + "::" + val)
  94. this.obj.value = val;
  95. }
  96. var valAr = val.split("^");
  97. this.cell.innerHTML = valAr[0];
  98. if (valAr.length > 1) {
  99. this.cell.funcToCall = valAr[1]
  100. }
  101. }
  102. this.detach = function() {
  103. alert(this.obj.value)
  104. this.setValue(this.obj.value);
  105. return this.val != this.getValue();
  106. }
  107. }
  108. eXcell_wbut.prototype = new eXcell;