SPZZZ01100_컬러피커.xrw 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?xml version="1.0" encoding="EUC-KR"?>
  2. <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2002/01/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
  3. <xhtml:head>
  4. <xhtml:title>Untitle</xhtml:title>
  5. <model id="model1">
  6. <instance id="instance1">
  7. <root xmlns="">
  8. <grid_colorpicker>
  9. <item/>
  10. <item/>
  11. <item/>
  12. <item/>
  13. <item/>
  14. <item/>
  15. <item/>
  16. <item/>
  17. <item/>
  18. <item/>
  19. </grid_colorpicker>
  20. </root>
  21. </instance>
  22. <script ev:event="xforms-model-construct-done" type="javascript">
  23. <![CDATA[
  24. var style = new Array("#fcd2c1" , "#ffe79d" , "#f3e1bf" , "#c6b3de" , "#b9e5fb" , "#f7a08b" , "#fec34d" , "#dec6a4" , "#c8e67b" , "#43c8f5" );
  25. for(var i = 0; i<style.length; i++) {
  26. grid_colorPicker.cellStyle("background-color", i, 0) = style[i];
  27. }
  28. ]]>
  29. </script>
  30. </model>
  31. <script type="javascript">
  32. <![CDATA[
  33. var _pWinObj; // 부모 윈도우 오브젝트
  34. var _pGridObj; // 부모 그리드 오브젝트
  35. function setColorState(colorState) {
  36. var pGridObj_statenode = _pGridObj.attribute("_statenode");
  37. var pGridStateNodePath = "";
  38. var pGridStateNode;
  39. if(pGridObj_statenode != "") {
  40. pGridStateNodePath = pGridObj_statenode
  41. pGridStateNode = _pWinObj.instance1.selectSingleNode(pGridStateNodePath);
  42. }
  43. else if(pGridObj_statenode == "") {
  44. var pGridObjNodeSet = _pGridObj.attribute("nodeset");
  45. var pGridObjNodeSetParentNodePath = "";
  46. var pGridObjNodeSetArray = pGridObjNodeSet.split("/");
  47. for(var i=1; i<pGridObjNodeSetArray.length-1; i++) {
  48. pGridObjNodeSetParentNodePath += "/" + pGridObjNodeSetArray[i];
  49. }
  50. var pGridSelMode = _pGridObj.selectionMode;
  51. var nodeName = "state";
  52. if(pGridSelMode == "free") {
  53. nodeName = "cellState";
  54. }
  55. else if(pGridSelMode == "list" || pGridSelMode == "byrow") {
  56. nodeName = "rowState";
  57. }
  58. pGridStateNodePath = pGridObjNodeSetParentNodePath + "/" + nodeName;
  59. pGridStateNode = _pWinObj.instance1.selectSingleNode(pGridStateNodePath);
  60. }
  61. var pGridStateNodeValue = "";
  62. if(pGridStateNode == null)
  63. _pWinObj.model.makeNode(pGridStateNodePath);
  64. else
  65. pGridStateNodeValue = _pWinObj.model.getValue(pGridStateNodePath);
  66. pGridStateNodeValue += colorState;
  67. _pWinObj.model.setValue(pGridStateNodePath, pGridStateNodeValue);
  68. }
  69. ]]>
  70. </script>
  71. </xhtml:head>
  72. <xhtml:body>
  73. <datagrid id="grid_colorPicker" nodeset="/root/grid_colorpicker/item" colsep="^" colwidth="100" defaultrows="10" focuscolor="transparent" mergecellsfixedrows="bycolrec" rowheight="20" rowsep="|" style="left:0px; top:0px; width:102px; height:202px; border-color:#c0c0c0; border-style:solid; ">
  74. <col ref="item"/>
  75. <script ev:event="onclick" type="javascript">
  76. <![CDATA[
  77. _pWinObj = parent.window;
  78. _pGridObj = _pWinObj.javaScript._gridObj;
  79. var selectedColor = grid_colorPicker.cellStyle("background-color", grid_colorPicker.row, 0);
  80. var pGridSelMode = _pGridObj.selectionMode;
  81. var returnColorState = "";
  82. var i;
  83. /* set color */
  84. if(pGridSelMode == "free") {
  85. var cellCollection = _pGridObj.selectedCells;
  86. var cell;
  87. for(i=0; i<cellCollection.length; i++) {
  88. cell = cellCollection.item(i);
  89. _pGridObj.cellStyle("background-color", cell.row, cell.col) = selectedColor;
  90. returnColorState += selectedColor + "^" + cell.row + "^" + cell.col + "|";
  91. }
  92. // setColorState("cellState", returnColorState);
  93. }
  94. else if(pGridSelMode == "list" || pGridSelMode == "byrow") {
  95. var row;
  96. for(i=0; i<_pGridObj.selectedRows; i++) {
  97. row = _pGridObj.selectedRow(i);
  98. _pGridObj.rowstyle(row, "data", "background-color") = selectedColor;
  99. returnColorState += selectedColor + "^" + row + "|";
  100. }
  101. // setColorState("rowState", returnColorState);
  102. }
  103. setColorState(returnColorState);
  104. _pWinObj.iviewer_colorPicker.attribute("height") = 0;
  105. ]]>
  106. </script>
  107. </datagrid>
  108. </xhtml:body>
  109. </xhtml:html>