";
this.dt = null;
this.col_list = null;
this.field_name_list = null;
this.get_field_list = function ()
{
var dt = this.dt;
var col_list = new Array();
var _field_list = new Array();
var str_template = this.str_template;
if (typeof(dt) == "undefined") {
this.field_name_list = "";
this.col_list = [];
return;
}
for (var col = 0; col < dt.getFieldCount(); col++)
{
var field_name = dt.getFieldName(col);
var target_name = "%" + field_name + "%";
if (str_template.indexOf(target_name) != -1
|| str_template.indexOf("%" + field_name + "_Source%") != -1 || field_name == "NO_NEW_LINE"
)
{
_field_list.push(field_name);
col_list.push(col);
}
}
this.field_name_list = _field_list;
this.col_list = col_list;
}
this.GetDataGrid = function ()
{
var i, strnum, j, rowCounter;
var dt = this.dt;
var strBuf = new StringBuilder();
var row, start, buf, strField, p_row;
var dt_row = 0, dt_col = 0;
var start_row = 0, end_row = 0;
var DataGrid = null;
var col_list = this.col_list;
var field_name_list = this.field_name_list;
var iGuid_row = 0;
var no_new_line_template = "
%namespace%.%FormName%.%ELE_NAME% | ";
var title = "";
var prev_td = false;
var top_tab_name ;
if (typeof(dt) == "undefined")
{
return "";
}
// no_new_line_template = no_new_line_template.ReplaceAll(
if (dt.getValue("TABS") == "")
{
j = 0;
rowCounter = 1;
start_row = 0;
end_row = dt.MaxRow();
DataGrid = this.str_template.split(this.str_split);
row = DataGrid.length - 3;
strBuf.Append("\n" + DataGrid[0]);
start = 2;
if (dt.getValue("ELE_NAME").indexOf("EditDetail") == 0 || dt.getValue("ELE_NAME").indexOf("AddNewDetail") == 0)
buf = "";
else
buf = DataGrid[1];
strBuf.Append("\n" + buf);
var next_no_new_line = false;
var no_td = "";
for (dt_row = start_row; dt_row < end_row; dt_row++)
{
buf = "";
p_row = j % row;
no_td = dt.getValueByRow(dt_row, "NO_TD");
var ele_type = dt.getValueByRow(dt_row, "ELE_TYPE");
var no_head = dt.getValueByRow(dt_row, "NO_HEAD");
var _class = dt.getValueByRow(dt_row, "CLASS");
var rowspan = dt.getValueByRow(dt_row, "ROWSPAN");
var ele_param = dt.getValueByRow(dt_row, "ELE_PARAM");
if (next_no_new_line)
{
if (no_td != "")
{
buf = (prev_td ? "" : "") + this.str_template_no_td;
}
else
{
if (dt.getValueByRow(dt_row, "WITH_HEAD") != "")
buf = this.str_template_with_head;
else
buf = this.str_template_no_new_line;
}
}
else
{
if (ele_type == "title") {
if (ele_param != "") {
buf = " | "
buf += " "
buf += "%TITLE% |
";
}
else
buf = " %TITLE% |
";
}
else if (ele_type == "hr") {
buf = "
|
"; }
else {
if (no_head != "")
{
buf = this.str_template_no_head ;
}
else
{
buf = DataGrid[start + p_row];
if (_class != "") {
buf = buf.ReplaceAll("class=\"editWindowColumn\"", "class=\"editWindowColumn %class%\"");
buf = buf.ReplaceAll("title=\"%ELE_MEMO_Source%\"\n", "title=\"%ELE_MEMO_Source%\" class=\"%class%\"\n ");
buf = buf.ReplaceAll(" XX : 用那個 buffer, YY : Colspan 數字
var marco_no = this.check_template_marco_no(buf);
var colspan_no = this.check_template_colspan(buf);
var colspan = "";
if (marco_no != -1)
{
if (colspan_no != -1)
{
colspan = "COLSPAN=" + colspan_no;
buf = buf.ReplaceAll("@@" + marco_no + "@@" + colspan_no + "@@", DataGrid[marco_no]);
}
else
buf = buf.ReplaceAll("@@" + marco_no + "@@", DataGrid[marco_no]);
}
// -------------------------------
if (buf.indexOf("%row%") != -1)
buf = buf.ReplaceAll("%row%", dt_row+1);
buf = buf.ReplaceAll("%COLSPAN%", colspan);
var no_line_colspan = dt.getValueByRow(dt_row, "COLSPAN") ;
if (no_line_colspan != "")
buf = buf.ReplaceAll("bgcolor=\"#FFFFFF\" id=", " COLSPAN=" + no_line_colspan + " bgcolor=\"#FFFFFF\" id=");
if (rowspan != "") buf = buf.ReplaceAll("\"%class%\"", "\"%class%\" rowspan=\"%rowspan%\"");
buf = buf.ReplaceAll("%colspan%", no_line_colspan);
buf = buf.ReplaceAll("%rowspan%",rowspan);
buf = buf.ReplaceAll("%class%", _class);
for (dt_col = 0; dt_col < col_list.length; dt_col++)
{
var FieldName = field_name_list[dt_col];
var _col = col_list[dt_col];
var _value = this.dt.getRowValueByCol(dt_row, _col);
if (FieldName == "NO_NEW_LINE")
{
if (_value != "")
{
if (next_no_new_line == false)
{
// buf = buf.ReplaceAll("bgcolor=\"#FFFFFF\" id=", "colspan=\"2\" bgcolor=\"#FFFFFF\" id=");
if (no_td != "")
buf = buf.ReplaceAll("", "");
buf = buf.ReplaceAll("
", "");
next_no_new_line = true;
}
}
else
{
if (next_no_new_line)
{
if (no_td != "")
buf += "";
buf += "";
next_no_new_line = false;
}
}
}
if (this.flg_show_html == 0) {
try {
_value = _value.ReplaceAll("&", "&");
_value = _value.ReplaceAll("<", "<");
_value = _value.ReplaceAll(">", ">");
_value = _value.ReplaceAll("\"", """);
}
catch (e) {}
}
if (this.flg_auto_breakline == 1) {
try {
_value = _value.ReplaceAll("\n", "
");
}
catch (e) {}
}
if (buf.indexOf("%" + FieldName + "_Source%") != -1) {
buf = buf.ReplaceAll("%" + FieldName + "_Source%", _value.Left(600).ReplaceAll("
", "\n"));
}
if (this.max_cols != -1 && _value.length > this.max_cols) {
_value = _value.Left(this.max_cols) + " ...";
}
// iGuid don't display
if (_value == "iGuid" && FieldName == "NAME")
{
iGuid_row = 1;
buf = buf.ReplaceAll("") < 0)
{
buf += "
";
};
strBuf.Append("\n" + buf);
iGuid_row = 0;
}
else
{
if (buf.indexOf("") == -1)
prev_td = false;
else
prev_td = true;
strBuf.Append("\n" + buf);
j += 1;
}
}
strBuf.Append("\n" + DataGrid[DataGrid.length-1]);
}
else
{
j = 0;
rowCounter = 1;
start_row = 0;
end_row = dt.MaxRow();
DataGrid = this.str_template.split(this.str_split);
row = DataGrid.length - 3;
//strBuf.Append("\n" + DataGrid[0]);
start = 2;
// buf = DataGrid[1];
// strBuf.Append("\n" + buf);
// 取得所有 TABS
var tabs = TABS;
var tabs_template = [];
var tabs_html = [];
var prefix = dt.getValue("TABS").split(".")[0];
top_tab_name = prefix + "_TOP";
for (var i = 0 ; i < tabs.length; i++)
{
k = prefix + "." + tabs[i];
if (i == 0)
tabs_template[k] = "" + DataGrid[0] + "%HTML%
";
else
tabs_template[k] = "" + DataGrid[0] + "%HTML%
";
tabs_html[k] = new StringBuilder();
}
tabs_template[top_tab_name] = "" + DataGrid[0] + "%HTML%
";
tabs_html[top_tab_name] = new StringBuilder();
var next_no_new_line = false;
var no_td = "";
var prev_td = false;
for (dt_row = start_row; dt_row < end_row; dt_row++)
{
var tab_name = dt.getValueByRow(dt_row, "TABS");
if (tab_name == "") tab_name = top_tab_name;
buf = "";
p_row = j % row;
no_td = dt.getValueByRow(dt_row, "NO_TD");
var ele_type = dt.getValueByRow(dt_row, "ELE_TYPE");
var no_head = dt.getValueByRow(dt_row, "NO_HEAD");
var _class = dt.getValueByRow(dt_row, "CLASS");
var rowspan = dt.getValueByRow(dt_row, "ROWSPAN");
var ele_param = dt.getValueByRow(dt_row, "ELE_PARAM");
if (next_no_new_line)
{
if (no_td != "")
{
buf = (prev_td ? "" : "") + this.str_template_no_td;
}
else
{
if (dt.getValueByRow(dt_row, "WITH_HEAD") != "")
buf = this.str_template_with_head;
else
buf = this.str_template_no_new_line;
}
}
else
{
if (ele_type == "title") {
if (ele_param != "") {
buf = " | "
buf += " %TITLE% |
";
}
else
buf = " %TITLE% |
";
}
else if (ele_type == "hr") {
buf = "
|
"; }
else
if (no_head != "")
{
buf = this.str_template_no_head ;
}
else
{
buf = DataGrid[start + p_row];
if (_class != "") {
buf = buf.ReplaceAll("class=\"editWindowColumn\"", "class=\"editWindowColumn %class%\"");
buf = buf.ReplaceAll("title=\"%ELE_MEMO_Source%\"\n", "title=\"%ELE_MEMO_Source%\" class=\"%class%\"\n ");
buf = buf.ReplaceAll(" XX : 用那個 buffer, YY : Colspan 數字
var marco_no = this.check_template_marco_no(buf);
var colspan_no = this.check_template_colspan(buf);
var colspan = "";
if (marco_no != -1)
{
if (colspan_no != -1)
{
colspan = "COLSPAN=" + colspan_no;
buf = buf.ReplaceAll("@@" + marco_no + "@@" + colspan_no + "@@", DataGrid[marco_no]);
}
else
buf = buf.ReplaceAll("@@" + marco_no + "@@", DataGrid[marco_no]);
}
// -------------------------------
if (buf.indexOf("%row%") != -1)
buf = buf.ReplaceAll("%row%", dt_row+1);
buf = buf.ReplaceAll("%COLSPAN%", colspan);
var no_line_colspan = dt.getValueByRow(dt_row, "COLSPAN") ;
if (no_line_colspan != "")
buf = buf.ReplaceAll("bgcolor=\"#FFFFFF\" id=", " COLSPAN=" + no_line_colspan + " bgcolor=\"#FFFFFF\" id=");
buf = buf.ReplaceAll("%colspan%", no_line_colspan);
if (rowspan != "") buf = buf.ReplaceAll("\"%class%\"", "\"%class%\" rowspan=\"%rowspan%\"");
buf = buf.ReplaceAll("%rowspan%", dt.getValueByRow(dt_row, "ROWSPAN"));
buf = buf.ReplaceAll("%class%", _class);
for (dt_col = 0; dt_col < col_list.length; dt_col++)
{
var FieldName = field_name_list[dt_col];
var _col = col_list[dt_col];
var _value = this.dt.getRowValueByCol(dt_row, _col);
if (FieldName == "NO_NEW_LINE")
{
if (_value != "")
{
if (next_no_new_line == false)
{
// buf = buf.ReplaceAll("bgcolor=\"#FFFFFF\" id=", "colspan=\"2\" bgcolor=\"#FFFFFF\" id=");
if (no_td != "")
buf = buf.ReplaceAll("", "");
buf = buf.ReplaceAll("
", "");
next_no_new_line = true;
}
}
else
{
if (next_no_new_line)
{
if (no_td != "")
buf += "";
buf += "";
next_no_new_line = false;
}
}
}
if (this.flg_show_html == 0) {
try {
_value = _value.ReplaceAll("&", "&");
_value = _value.ReplaceAll("<", "<");
_value = _value.ReplaceAll(">", ">");
_value = _value.ReplaceAll("\"", """);
}
catch (e) {}
}
if (this.flg_auto_breakline == 1) {
try {
_value = _value.ReplaceAll("\n", "
");
}
catch (e) {}
}
if (buf.indexOf("%" + FieldName + "_Source%") != -1) {
buf = buf.ReplaceAll("%" + FieldName + "_Source%", _value.Left(600).ReplaceAll("
", "\n"));
}
if (this.max_cols != -1 && _value.length > this.max_cols) {
_value = _value.Left(this.max_cols) + " ...";
}
// iGuid don't display
if (_value == "iGuid" && FieldName == "NAME")
{
iGuid_row = 1;
buf = buf.ReplaceAll("") < 0)
{
buf += "
";
};
tabs_html[tab_name].Append("\n" + buf);
iGuid_row = 0;
}
else
{
if (buf.indexOf("") == -1)
prev_td = false;
else
prev_td = true;
tabs_html[tab_name].Append("\n" + buf);
j += 1;
}
}
tabs_template[top_tab_name] = tabs_template[top_tab_name].ReplaceAll("%HTML%", tabs_html[top_tab_name].ToString() + "\n" + DataGrid[DataGrid.length-1] );
strBuf.Append(tabs_template[top_tab_name]);
if (tabs_html[top_tab_name]._buf.length > 0) strBuf.Append("\n
");
strBuf.Append("\n" + DataGrid[1]); // 設定 Tab 的畫面
for (var i = 0 ; i < tabs.length; i++)
{
var k = prefix + "." + tabs[i]
tabs_template[k] = tabs_template[k].ReplaceAll("%HTML%", tabs_html[k].ToString() + "\n" + DataGrid[DataGrid.length-1] );
strBuf.Append(tabs_template[k]);
}
// strBuf.Append("\n" + DataGrid[DataGrid.length-1]);
}
return(strBuf.ToString());
}
this.check_template_marco_no = function (str_template)
{
if (typeof(str_template) == "undefined") return -1;
if (str_template.indexOf("@@") != -1)
{
var t_array = str_template.split("@@");
if (t_array.length > 2)
return (t_array[1]);
else
return (-1);
}
else
return (-1);
}
this.check_template_colspan = function (str_template)
{
if (str_template.indexOf("@@") != -1)
{
var t_array = str_template.split("@@");
if (t_array.length > 3)
return (t_array[2]);
else
return (-1);
}
else
return (-1);
}
}
-->