아래 샘플에서는 가우스 MGrid의 ColumnInfo부분의 Header에 몇가지 프로퍼티를 추가하는 샘플이다.
ColumnInfo부분이 XML구조이기 때문에 XML DOM객체를 생성후에
DOM객체에 XPATH를 적용하여 HEADER리스트만 뽑아온 이후 HEADER에 몇가지 프로퍼티를 추가한
샘플이다.
샘플 수행후 헤더의 값을 확인해 보면
변경전
-----------------------------------------------------------------------------------
<COLUMN id="id_albuminfo" view="false" index="1">
<HEADER left="100" top="0" right="550" bottom="20" text="Album 정보 (index=1)"/>
</COLUMN>
변경후
-----------------------------------------------------------------------------------
<COLUMN id="id_albuminfo" view="false" index="1">
<HEADER left="100" top="0" right="550" bottom="20" text="Album 정보 (index=1)" bgcolor="blue" color="red" fontstyle="Underline" fontsize="10" fontname="돋움"/>
</COLUMN>
bold체로 된 부분이 추가되어진 것을 확인 할 수 있다.
아래 샘플은 MGrid의 색상등을 지정하기 위해 만든 샘플 코드 이다.
펼쳐두기..
<Html>
<Head>
<STYLE>
BODY { font:10pt; }
</STYLE>
<object id="Dataset" classid="clsid:2506B38B-0FF7-4249-BA3E-8BC1DC399FBB">
<Param Name="DataID" value="dataset.csv">
</object>
</Head>
<Script>
function MGridStyle(p_obj) {
var MGRID = p_obj;
var className = MGRID.className;
var header_BgColor; // Header BgColor;
var header_Color; // Header Color;
var header_FontStyle; // Header FontStyle
var header_FontSize; // Header FontSize;
var header_FontName; // Header FontName;
switch(className) {
case "comn":
header_BgColor = "blue";
header_Color = "red";
header_FontStyle = "Underline";
header_FontSize = "10";
header_FontName = "돋움";
break;
}
var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
doc.async = false;
doc.loadXML(MGRID.ColumnInfo);
var headerList = doc.selectNodes("/COLUMNINFO/COLUMN/HEADER"); // XPATH
var attribute;
for (i=0;i<headerList.length ; i++) {
attribute = doc.createAttribute("bgcolor");
attribute.nodeValue = header_BgColor;
headerList.item(i).attributes.setNamedItem(attribute);
attribute = doc.createAttribute("color");
attribute.nodeValue = header_Color;
headerList.item(i).attributes.setNamedItem(attribute);
attribute = doc.createAttribute("fontstyle");
attribute.nodeValue = header_FontStyle;
headerList.item(i).attributes.setNamedItem(attribute);
attribute = doc.createAttribute("fontsize");
attribute.nodeValue = header_FontSize;
headerList.item(i).attributes.setNamedItem(attribute);
attribute = doc.createAttribute("fontname");
attribute.nodeValue = header_FontName;
headerList.item(i).attributes.setNamedItem(attribute);
}
MGRID.ColumnInfo = doc.xml;
}
function fcOnload() {
MGridStyle(MGrid);
}
</script>
<Body onload="fcOnload()">
<table frame=box width=800>
<tr>
<td>CountColumn</td>
<td width=200>MGrid</td>
</tr>
</table><br>
<u>Get Column Count</u>
<select id=sel onChange="alert('count : '+MGrid.CountColumn(Number(sel.value)));">
<option value="1" selected> CountColumn(1)
<option value="2"> CountColumn(2)
<option value="3"> CountColumn(3)
</select><br><br>
<object id="MGrid" class="comn" classid="clsid:8B6E903C-6297-44FB-B6C5-4F9D7FCA2A08" width=800 height=500>
<Param Name="DataID" value="Dataset">
<Param Name="ColumnInfo" value='
<COLUMNINFO>
<COLUMN id="id_artist" refcolid="artist">
<HEADER left="0" top="0" right="100" bottom="60" text="Artist"/>
<VIEW left="0" top="0" right="100" bottom="40"/>
</COLUMN>
<COLUMN id="id_albuminfo" view="false" index="1">
<HEADER left="100" top="0" right="550" bottom="20" text="Album 정보 (index=1)"/>
</COLUMN>
<COLUMN id="id_albumname" refcolid="albumname" index="2">
<HEADER left="100" top="20" right="450" bottom="40" text="Album 이름 (index=2)"/>
<VIEW left="100" top="0" right="450" bottom="20"/>
</COLUMN>
<COLUMN id="id_title" refcolid="title" index="3">
<HEADER left="100" top="40" right="300" bottom="60" text="대표곡 (index=3)"/>
<VIEW left="100" top="20" right="300" bottom="40"/>
<CHILD type="edit" ime="english"/>
</COLUMN>
<COLUMN id="id_releasedate" refcolid="releasedate">
<HEADER left="300" top="40" right="380" bottom="60" text="발매일"/>
<VIEW left="300" top="20" right="380" bottom="40" displayformat="XXXX-XX-XX"/>
</COLUMN>
<COLUMN id="id_genre" refcolid="genre">
<HEADER left="380" top="40" right="450" bottom="60" text="쟝르"/>
<VIEW left="380" top="20" right="450" bottom="40"/>
<CHILD type="combo" showitemcount="3">
<COMBOITEM code="1" text="Thrash"/>
<COMBOITEM code="2" text="Death"/>
<COMBOITEM code="3" text="Black"/>
<COMBOITEM code="4" text="Ect"/>
</CHILD>
</COLUMN>
<COLUMN id="id_albumstate" view="false">
<HEADER left="450" top="20" right="550" bottom="40" text="Album 상태"/>
</COLUMN>
<COLUMN id="id_totalstock" refcolid="totalstock">
<HEADER left="450" top="40" right="500" bottom="60" text="재고량"/>
<VIEW left="450" top="0" right="500" bottom="40"/>
<CHILD type="edit" inputtype="num"/>
</COLUMN>
<COLUMN id="id_rerelease" refcolid="rerelease">
<HEADER left="500" top="40" right="550" bottom="60" text="재발매"/>
<VIEW left="500" top="0" right="550" bottom="40" text="@DECODE(rerelease,0,[N/A],1,[문의요])"/>
</COLUMN>
<COLUMN id="id_user" refcolid="user">
<HEADER left="550" top="0" right="700" bottom="30" text="평가자"/>
<VIEW left="550" top="0" right="700" bottom="20"/>
</COLUMN>
<COLUMN id="id_score" refcolid="score">
<HEADER left="550" top="30" right="600" bottom="60" text="점수"/>
<VIEW left="550" top="20" right="600" bottom="40"/>
</COLUMN>
<COLUMN id="id_opinion" refcolid="opinion">
<HEADER left="600" top="30" right="700" bottom="60" text="감상평"/>
<VIEW left="600" top="20" right="700" bottom="40" align="leftcenter" leftmargin="2" rightmargin="1"/>
<CHILD type="edit" subtype="popup"/>
</COLUMN>
<COLUMN id="id_purchase" refcolid="purchase">
<HEADER left="700" top="0" right="750" bottom="60" text="구매"/>
<VIEW left="700" top="0" right="750" bottom="40"/>
<CHILD type="check"/>
</COLUMN>
</COLUMNINFO>'>
</object>
</Body>
</Html>
No comments:
Post a Comment