"; page_control_list = this.str_page_control_template.split(""); strBuf.Append("\n" + page_control_list[0]); strBuf.Append("\n" + page_control_list[1]); for (var i = 1; i <= this.dt._MaxPageNumber; i++) { var _buf = page_control_list[2]; _buf = _buf.ReplaceAll("%PageNum%", i); strBuf.Append("\n" + _buf); } strBuf.Append("\n" + page_control_list[3]); strBuf.replace("%this.str_page_first%", this.str_page_first); strBuf.replace("%this.str_page_up%", this.str_page_up); strBuf.replace("%this.str_page_down%", this.str_page_down); strBuf.replace("%this.str_page_last%", this.str_page_last); strBuf.replace("%this.str_page_list%", this.str_page_list); strBuf.replace("%this.str_page_size%", this.str_page_size); strBuf.replace("%this.str_total_record%", this.str_total_record); strBuf.replace("%TotalRecord%", this.dt.MaxRow()); strBuf.replace("%ControlName%", this.control_name); strBuf.replace("%PageSize%", this.dt._PageSize); return (strBuf); } /************************MARK******************************/ this.GetPageDataGrid = function () { var i, strnum, j, rowCounter; 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 = new Array(); var col_list = new Array(); var field_name_list = new Array(); j = 0; rowCounter = 1; start_row = (this.dt._PageNumber - 1) * this.dt._PageSize; if (start_row < 0) start_row = 0; end_row = start_row + this.dt._PageSize; //alert("end_row = " + end_row); if (end_row > this.dt.MaxRow()) end_row = this.dt.MaxRow(); for (dt_col = 0; dt_col < this.dt.getFieldCount(); dt_col++) { var FieldName = this.dt.getFieldName(dt_col); var _col = this.dt.SearchFieldName(FieldName); field_name_list.push(FieldName); col_list.push(_col); } if (this.strTemplate == "") this.strTemplate = this.CreateTemplate(); if (this.strSplit == "") this.strSplit = ""; this.strTemplate = this.strTemplate.ReplaceAll("%ControlName%", this.control_name); DataGrid = this.strTemplate.split(this.strSplit); row = DataGrid.length - 3; strBuf.Append("\n" + DataGrid[0]); start = 2; buf = DataGrid[1]; strBuf.Append("\n" + buf); for (dt_row = start_row; dt_row < end_row; dt_row++) { buf = ""; p_row = j % row; buf = DataGrid[start + p_row]; buf = buf.ReplaceAll("%row%", dt_row); buf = buf.ReplaceAll("%show_row%", dt_row+1); // 雙色顯示 if (this.tr_dual_color) { if (dt_row % 2 == 1){ buf = buf.ReplaceAll("%class%", "class=\"" + this.tr_class2 + "\""); buf = buf.ReplaceAll("%color%", "bgcolor=\"" + this.tr_color2 + "\""); }else{ buf = buf.ReplaceAll("%class%", "class=\"" + this.tr_class1 + "\""); buf = buf.ReplaceAll("%color%", "bgcolor=\"" + this.tr_color1 + "\"");} } else buf = buf.ReplaceAll("%class%", "class=\"" + this.tr_class1 + "\""); for (dt_col = 0; dt_col < this.dt.getFieldCount(); dt_col++) { //var FieldName = this.dt.getFieldName(dt_col); //buf = buf.ReplaceAll("%" + FieldName + "%", this.dt.getRowValue(dt_row, FieldName)); var FieldName = field_name_list[dt_col]; var _col = col_list[dt_col]; var _value = this.dt.getRowValueByCol(dt_row, _col); if (this.flg_auto_breakline == 1) { try { _value = _value.ReplaceAll("&", "&"); _value = _value.ReplaceAll("<", "<"); _value = _value.ReplaceAll(">", ">"); _value = _value.ReplaceAll("\"", """); _value = _value.ReplaceAll("\n", "
"); } catch (e) {} } if (buf.indexOf("%" + FieldName + "_Source%") != -1) { _value += ""; buf = buf.ReplaceAll("%" + FieldName + "_Source%", _value.Left(500).ReplaceAll("
", "\n")); } if (this.max_cols != -1 && _value.length > this.max_cols) { _value = _value.Left(this.max_cols) + " ..."; } // 使用者可自訂 before_td 函數在 oDataGrid 之前, 以客製化TD try {buf = before_td(dt,buf,FieldName, _value);} catch(e) {}; buf = buf.ReplaceAll("%Cust_TD_" + FieldName + "%", "") // by thomas 數字向右對齊 var fieldType = this.dt.getFieldType(dt_col); switch (fieldType) { case "System.Decimal": case "System.Integer": case 'System.Double': case 'System.Int32': buf = buf.ReplaceAll("%TD_" + FieldName + "%", "align=right"); break; default: buf = buf.ReplaceAll("%TD_" + FieldName + "%", ""); } // 格式化字串 var str_format = this.get_format(FieldName) ; if (str_format != "") { _value = Format(_value, str_format ); } // 使用者可自訂 before_td 函數在 oDataGrid 之前, 以客製化TD // try {buf = before_value(dt,buf,FieldName,_value);} catch(e) {} this.before_display_value(dt,buf,FieldName,_value); // Grid 中可選 CheckBox if (FieldName == "_select") { var element_name = "Search._select" var element_param = "" element_param += " onblur=\"JavaScript:%ControlName%.td_onblur(%row%, '%ColumnName%', this.value);\""; element_param = element_param.ReplaceAll("%row%", dt_row); element_param = element_param.ReplaceAll("%ColumnName%", FieldName); element_param = element_param.ReplaceAll("%ControlName%", this.control_name); element_param += " size='1' "; element_param += " value='1' "; var display_content = "      " display_content = display_content.ReplaceAll("%name%", element_name + "_" + (dt_row+1).toString()); display_content = display_content.ReplaceAll("%element_param%", element_param); buf = buf.ReplaceAll("%" + FieldName + "%", display_content); } // Grid 中可選 radio if (FieldName == "_radio"){ var element_name = "Search._radio" var element_param = "" element_param += " onblur=\"JavaScript:%ControlName%.td_onblur(%row%, '%ColumnName%', this.value);\""; element_param += " onclick=\"JavaScript:event.cancelBubble=true;\""; element_param = element_param.ReplaceAll("%row%", dt_row); element_param = element_param.ReplaceAll("%ColumnName%", FieldName); element_param = element_param.ReplaceAll("%ControlName%", this.control_name); element_param += " size='1' "; var radioItem=this.dt.getValue("_radio").split(","); var display_content=""; var display_content2=""; for(var iit=0;iit" display_content += "" + _raTitle +"" display_content = display_content.ReplaceAll("%name%", element_name + "_" + (dt_row+1).toString()); display_content = display_content.ReplaceAll("%element_param%", element_param); display_content2 += display_content } buf = buf.ReplaceAll("%" + FieldName + "%", display_content2); } if (this.get_allow_edit(FieldName) == "1" && FieldName != "_select" && FieldName != "_radio") { var s_row = this.schema_dt.Search("NAME",FieldName); var element_name = this.schema_dt.getValueByRow(s_row, "ELE_NAME"); var element_type = this.schema_dt.getValueByRow(s_row, "ELE_TYPE"); var str_not_null = dt.getValueByRow(row, "NOT_NULL"); var str_url = this.schema_dt.getValueByRow(s_row, "URL"); var str_element_list = this.schema_dt.getValueByRow(s_row, "ELE_LIST"); var display_content = "" var element_param = ""; var form = new clsForm(); switch (element_type) { case "text": display_content = form.create_textbox(s_row, element_name , element_param, this.schema_dt, dt_row+1, this.control_name, _value, FieldName); break; case "select": case "checkbox": case "radiobutton": element_param += " onblur=\"JavaScript:%ControlName%.td_onblur(%row%, '%ColumnName%', this.value);\""; element_param = element_param.ReplaceAll("%row%", dt_row); element_param = element_param.ReplaceAll("%ColumnName%", FieldName); element_param = element_param.ReplaceAll("%ControlName%", this.control_name); element_param += " size='1' "; element_param += " value='" + _value + "' "; var _dt = this.schema_dt.getValueByRow(s_row , "DATA"); if (_dt == "") { if (element_type == "select") { var _dt = form.create_listbox(s_row, element_name, element_param, str_url, str_element_list, this.schema_dt, dt_row+1, this.control_name, _value, FieldName ); } if (element_type == "checkbox") { var _dt = form.create_checkbox(s_row, element_name, element_param, str_url, str_element_list, this.schema_dt, dt_row+1, this.control_name, _value, FieldName ); } if (element_type == "radiobutton") { var _dt = form.create_checkbox(s_row, element_name, element_param, str_url, str_element_list, this.schema_dt, dt_row+1, this.control_name, _value, FieldName ); } this.schema_dt.setValueByRow(s_row , "DATA", _dt); } if (element_type == "select") var display_content = _dt.getListBox(element_name+"_"+ (dt_row+1).toString(), element_param, "0", "1", str_not_null); if (element_type == "checkbox") var display_content = _dt.getCheckBox(element_name+"_"+ (dt_row+1).toString(), element_param, "0", "1", str_not_null); if (element_type == "radiobutton") var display_content = _dt.getRadioButton(element_name+"_"+ (dt_row+1).toString(), element_param, "0", "1", str_not_null); break; default: var div_name = "display.form.FormName." + element_name + "_" + (dt_row+1).toString() ; display_content += "
"; display_content += " "; buf = buf.ReplaceAll("%" + FieldName + "%", display_content); continue; break; } display_content += " "; if (_value != "") { var t_func = function (__name, __value) { set_element_value(__name,__value); }; if (this.functions == null) this.functions = new Array(); if (this.functions_1 == null) this.functions_1 = new Array(); if (this.functions_2 == null) this.functions_2 = new Array(); this.functions.push(t_func); this.functions_1.push(element_name+ "_" + (dt_row+1).toString()); this.functions_2.push(_value); } buf = buf.ReplaceAll("%" + FieldName + "%", display_content); } else buf = buf.ReplaceAll("%" + FieldName + "%", _value); } strBuf.Append("\n" + buf); j += 1; } strBuf.Append("\n" + DataGrid[DataGrid.length-1]); // 產生合計 if (this.settings.sum_list != "") { strBuf.Append("
"); var sum_array = this.settings.sum_list.split(","); for (var sum_cnt=0; sum_cnt < sum_array.length; sum_cnt++) { var field = sum_array[sum_cnt].split("|"); var digits = 3; if (field.length == 3) digits = field[2]; strBuf.Append(field[0] + " " + FormatNumber(this.dt.sum(field[1]),digits) + "    "); } } return(strBuf); } this.CreateTemplate = function () { var str = new StringBuilder(); var str_row = new StringBuilder(); var str_head = new StringBuilder(); var str_show_fields = ""; var str_column_name = ""; var str_column_title = ""; var i_show_fields = new Array(); if (this.settings.column_mapping.column == "") { var _column_list = ""; for (var col = 0; col < this.dt.getFieldCount(); col++) { var FieldName = this.dt.getFieldName(col); if (_column_list == "") _column_list = FieldName; else _column_list += "," + FieldName; } this.settings.column_mapping.column = _column_list; } if (this.settings.column_mapping.title == "") this.settings.column_mapping.title = this.settings.column_mapping.column str_column_name = this.settings.column_mapping.column.split(","); str_column_title = this.settings.column_mapping.title.split(","); if (str_column_name.length != str_column_title.length) { alert("column_name.length = " + str_column_name.length + "\n column_title.length = " + str_column_name.length + "\n the number of length is not match ..!" ); return (false); } //Start Generate Head Template------------------------------------------------------ str_head.Append("\n"); str_head.Append(""); for (var icol = 0; icol < this.columns; icol++) { if (this.flg_row_number == 1) { str_head.Append("\n 列數"); } if (this.flg_row_control == 1) { str_head.Append("\n 控制項"); } for (var col = 0; col < str_column_title.length; col++) { var _buf = new StringBuilder(); var FieldName = str_column_title[col]; var _col = this.dt.getFieldIndex(str_column_name[col]); _buf.Append("\n %ColumnTitle% "); _buf.replace("%ColumnTitle%", FieldName); _buf.replace("%ColumnName%", str_column_name[col]); if (_col != -1) _buf.replace("%ColumnType%", this.dt.getFieldType(_col)); else _buf.replace("%ColumnType%", "System.String"); str_head.Append(_buf.ToString()); } } str_head.Append("\n "); //End Generate Head Template------------------------------------------------------ //Start Generate Row Template------------------------------------------------------ str_row.Append("\n "); for (var icol = 0; icol < this.columns; icol++) { if (this.flg_row_number == 1) { str_row.Append("\n " + "\n %show_row%" + "\n "); } if (this.flg_row_control == 1) { if (this.flg_delete_control == 0) str_row.Append("\n "); else str_row.Append("\n "); str_row.Append("\n "); if (this.flg_delete_control == 0) { str_row.Append("\n "); str_row.Append("\n "); } } for (var col = 0; col < str_column_name.length; col++) { var _buf = new StringBuilder(); var FieldName = str_column_name[col]; _buf.Append("\n " + "\n %%ColumnName%%" + "\n "); _buf.replace("%ColumnName%", FieldName); _buf.replace("%DataAttribute%","TD_" + FieldName); _buf.replace("%CustDataAttribute%","Cust_TD_" + FieldName); str_row.Append(_buf.ToString()); } str_row.Append("\n "); } str_row.Append("\n "); //End Generate Row Template------------------------------------------------------- if(this.control_name == "o_DetailGrid.dg" || this.control_name == "o_DetailGrid2.dg"){ str.Append("\n"); }else{ str.Append("\n
"); } str.Append("" ); str.Append(" "); str.Append(""); str.Append(""); str.Append(" "); str.Append(" "); str.Append(" "); str.Append(""); str.Append("" ); str.Append(" "); str.Append("\n"); str.Append("" ); str.Append(" "); str.Append(""); str.Append("\n
"); str.Append("\n "); str.Append("\n"); //列數 部門編號 部門名稱 上層單位 str.Append(str_head.ToString()); //insert table head into template str.Append("\n"); str.Append(str_row.ToString()); //insert row data into template // str.Append("\n"); str.Append(str_row.ToString()); //insert row data into template // str.Append("\n"); str.Append("\n
"); str.Append("\n
"); str.Append("
"); return (str.ToString()); } /************************MARK******************************/ /*******************設定分頁********************/ this.CreatePageControlTemplate = function () { var strBuf = new StringBuilder(); strBuf.Append("\n ") strBuf.Append("\n ") strBuf.Append("\n "); strBuf.Append("\n "); strBuf.Append("\n "); strBuf.Append("\n
") strBuf.Append("\n ") strBuf.Append("\n ") strBuf.Append("\n "); strBuf.Append("\n %this.str_page_list%"); strBuf.Append("\n"); strBuf.Append("\n "); strBuf.Append("\n %this.str_page_size%" + "\n "); strBuf.Append("\n %this.str_total_record% %TotalRecord%
"); return (strBuf.ToString()); } /************************MARK******************************/ /********************************************************************************************** *** 設定 資料欄 onclick 的事件處理 : this.td_onclick = function (row, ColumnName) *** *********************************************************************************************** *** 可重新定義 資料欄 onclick 事件處理模式: *** *** 重新定義:this.after_td_onclick = function(row, ColumnName) *** *** *** ***********************************************************************************************/ this.td_onclick = function (row, ColumnName) { if (this.flg_edit_column == 1) if (this.get_allow_edit(ColumnName) == "1") { // this.show_edit_column(row, ColumnName); } else { try { this.$ele(this.control_name + ".edit.column.cancel")[0].onclick(); } catch (e) { } } this.after_td_onclick(row, ColumnName); } this.create_elements = function () { var col_list = new Array(); var field_name_list = new Array(); var dt_row = 0, dt_col = 0; var start_row = 0, end_row = 0; start_row = (this.dt._PageNumber - 1) * this.dt._PageSize; if (start_row < 0) start_row = 0; end_row = start_row + this.dt._PageSize; if (end_row > this.dt.MaxRow()) end_row = this.dt.MaxRow(); for (dt_col = 0; dt_col < this.dt.getFieldCount(); dt_col++) { var FieldName = this.dt.getFieldName(dt_col); var _col = this.dt.SearchFieldName(FieldName); field_name_list.push(FieldName); col_list.push(_col); } for (dt_row = start_row; dt_row < end_row; dt_row++) { for (dt_col = 0; dt_col < this.dt.getFieldCount(); dt_col++) { var FieldName = field_name_list[dt_col]; var _col = col_list[dt_col]; var _value = this.dt.getRowValueByCol(dt_row, _col); if (this.get_allow_edit(FieldName) == "1" && FieldName != "_select" && FieldName != "_radio") { var s_row = this.schema_dt.Search("NAME",FieldName); var element_name = this.schema_dt.getValueByRow(s_row, "ELE_NAME"); var element_type = this.schema_dt.getValueByRow(s_row, "ELE_TYPE"); var str_not_null = this.schema_dt.getValueByRow(s_row, "NOT_NULL"); var str_url = this.schema_dt.getValueByRow(s_row, "URL"); var str_element_list = this.schema_dt.getValueByRow(s_row, "ELE_LIST"); var display_content = "" var element_param = ""; var form = new clsForm(); form.detail_dt = this.schema_dt; switch (element_type) { case "index_button_textbox": element_name = element_name + "_" + (dt_row+1).toString() display_content = form.create_index_button_textbox(s_row, element_name, element_param, str_url, str_element_list, this.schema_dt, dt_row+1, this.control_name, _value, FieldName); set_element_value(element_name, _value); break; } //switch } // if } // for dt_col } // for dt_row } this.after_td_onclick = function(row, ColumnName) { } this.th_onclick = function (ColumnName) { if (this.flg_sort == 1) this.sort_event(ColumnName); this.after_th_onclick(ColumnName); } this.after_th_onclick = function(ColumnName) { } // DataGrid event Table Head on Mouse Over this.th_onmouseover = function (this_th, ColumnName) { if (this.flg_th_tip == 1) { this_th.style.cursor='Pointer' this.set_message(this.get_th_tip(ColumnName)); } this.after_th_onmouseover(this_th, ColumnName); } this.th_onmouseout = function (this_th, ColumnName) { if (this.flg_th_tip == 1) { this_th.style.cursor='default' this.set_message(""); } this.after_th_onmouseout(this_th, ColumnName); } this.after_th_onmouseover = function(this_th, ColumnName) { } this.after_th_onmouseout = function(this_th, ColumnName) { } //--------------------------------------------------------- // DataGrid event Table Row on Mouse Over this.tr_onclick = function (this_tr, row) { this.after_tr_onclick(this_tr, row); } this.after_tr_onclick = function(this_tr, row) { } //在ROW上移動時,變色的控制 this.tr_onmouseover = function (this_tr, row) { this_tr.style.cursor='Pointer'; this.tr_old_bgcolor = this_tr.bgColor; this_tr.bgColor='#f9b5c2'; // this_tr.bgColor='#fde9ed'; // this_tr.bgColor='#fbc8de'; // this_tr.bgColor='#fed4d5'; // this.tr_old_color = this_tr.style.color; // this_tr.style.color='#696969'; this.after_tr_onmouseover(this_tr, row); } this.tr_onmouseout = function (this_tr, row) { this_tr.style.cursor='default'; this_tr.bgColor=this.tr_old_bgcolor; // this_tr.style.color=this.tr_old_color; this.after_tr_onmouseout(this_tr, row); } this.after_tr_onmouseover = function(this_tr, row) { } this.after_tr_onmouseout = function(this_tr, row) { } //--------------------------------------------------------- // DataGrid event Table Column on Mouse Over this.td_onmouseover = function (this_td, ColumnName) { if (this.flg_td_tip == 1) { this_td.style.cursor='Pointer' this.set_message(this.get_td_tip(ColumnName)); } this.after_td_onmouseover(this_td, ColumnName); } this.td_onmouseout = function (this_td, ColumnName) { if (this.flg_td_tip == 1) { this_td.style.cursor='default' this.set_message(""); } this.after_td_onmouseout(this_td, ColumnName); } this.after_td_onmouseover = function(this_td, ColumnName) { } this.after_td_onmouseout = function(this_td, ColumnName) { } //--------------------------------------------------------- this.sort_event = function (ColumnName) { var str_execute = "%ControlName%.dt.sort(%ControlName%.sort_column_name, %ControlName%.sort_type);" + "\n%ControlName%.refresh();" + "\n%ControlName%.set_message('');" + "\n%ControlName%.in_process_logo('');"; str_execute = str_execute.ReplaceAll("%ControlName%", this.control_name); //this.$obj(this.display_name + "_DataGrid").innerHTML = this.running_img; this.in_process_logo(this.img_loading); if (ColumnName != this.sort_column_name) { this.sort_column_name = ColumnName; this.sort_type = "ASC"; } else { if (this.sort_type == "ASC") this.sort_type = "DESC"; else this.sort_type = "ASC"; } this.set_message("Sort By " + this.get_column_title(ColumnName) + " " + this.sort_type); window.setTimeout(str_execute, 100); } this.in_process_logo = function (_logo) { var id_name_msg = this.display_name + "_in_process"; if (_logo == "") { this.$obj(this.display_name + "_in_process").innerHTML = ""; hide_div(id_name_msg); this.$obj(id_name_msg).style.zIndex = 1; } else { set_id_position(id_name_msg , document.body.scrollLeft + document.body.clientWidth - 130 , document.body.scrollTop ); this.$obj(id_name_msg).style.zIndex = 100; show_div(id_name_msg); this.$obj(id_name_msg).innerHTML = _logo; } } this.set_message = function (msg) { var msg_templtae = this.msg_template; var mouse_point = get_mouse_point(); var id_name_msg = this.display_name + "_message"; msg_templtae = msg_templtae.ReplaceAll("%msg%", msg); /* + "\n
scrollLeft = " + document.documentElement.scrollLeft + "\n
scrollTop = " + document.documentElement.scrollTop ); */ if (msg == "") { this.$obj(this.display_name + "_message").innerHTML = ""; hide_div(id_name_msg); } else { setOpacity(id_name_msg, 7) set_id_position(id_name_msg, mouse_point[0]+10, mouse_point[1]-50); show_div(id_name_msg); this.$obj(id_name_msg).innerHTML = msg_templtae; } } this.get_td_tip = function (col_name) { var column_list = this.settings.column_mapping.column.split(","); var tip_list = this.settings.column_mapping.td_tip.split(","); var i_name = column_list.indexOf(col_name); var str = "可對欄位
『%column_name%』
進行編輯"; if (this.settings.column_mapping.td_tip == "") { str = str.ReplaceAll("%column_name%", this.get_column_title(col_name)); if (this.get_allow_edit(col_name) == "0") str = str.ReplaceAll("可對欄位", "不可對欄位"); return (str); } if (i_name != -1) str = tip_list[i_name]; return (str); } this.get_th_tip = function (col_name) { var column_list = this.settings.column_mapping.column.split(","); var tip_list = this.settings.column_mapping.th_tip.split(","); var i_name = column_list.indexOf(col_name); var str = "可根據欄位
『%column_name%』
進行排序"; if (this.settings.column_mapping.th_tip == "") { str = str.ReplaceAll("%column_name%", this.get_column_title(col_name)); return (str); } if (i_name != -1) { str = tip_list[i_name]; //str = tip_list[i_name] + "
(" + this.dt.getFieldType(i_name) + ")"; } return (str); } this.get_column_title = function (col_name) { var column_list = this.settings.column_mapping.column.split(","); var title_list = this.settings.column_mapping.title.split(","); var i_name = column_list.indexOf(col_name); var str_title = ""; if (i_name != -1) str_title = title_list[i_name]; if (str_title == "") str_title = col_name; return (str_title); } this.get_allow_edit = function (col_name) { if (this.settings.column_mapping.allow_edit == "") return ("1"); var column_list = this.settings.column_mapping.column.split(","); var allow_edit_list = this.settings.column_mapping.allow_edit.split(","); var i_name = column_list.indexOf(col_name); var str_allow_edit = ""; if (i_name != -1) str_allow_edit = allow_edit_list[i_name]; if (str_allow_edit == "") str_allow_edit = "0"; return (str_allow_edit); } this.get_format = function (col_name) { if (this.settings.format_list == "") return (""); var column_list = this.settings.column_mapping.column.split(","); var format_list = this.settings.format_list.split("|"); var i_name = column_list.indexOf(col_name); var str_format = ""; if (i_name != -1) str_format = format_list[i_name]; return (str_format); } this.insert_new_row = function () { this.dt.InsertNewRow(0); this.refresh(); } this.add_new_row = function () { this.dt.AddNewRow(); this.refresh(); } this.delete_row = function (row) { try { this.dt.RemoveRowByNumber(row); this.refresh(); } catch (e) { alert(e.Message); } } this.delete_last_row = function () { this.dt.RemoveLastRow(); this.refresh(); } this.show_edit_column = function (row, ColumnName) { var display_edit_column = this.display_name + "_edit_column"; var str_edit_form = this.edit_column_template; var mouse_point = get_mouse_point(); var the_dg = this; var ColumnValue = this.dt.getValueByRow(row, ColumnName); var str_textbox_name = this.control_name + ".edit.column.textbox"; var str_target_name = display_edit_column; var str_trigger_name = "display.%ControlName%.EditColumn.trigger".ReplaceAll("%ControlName%", this.control_name); str_edit_form = str_edit_form.ReplaceAll("%ControlName%", this.control_name); set_id_position(display_edit_column, mouse_point[0]-100, mouse_point[1]); show_div(display_edit_column); //setOpacity(display_edit_column, 8.5); this.$obj(display_edit_column).innerHTML = str_edit_form; this.$obj(this.control_name + ".EditColumn.title").innerHTML = this.str_edit_column_title; this.$obj(this.control_name + ".EditColumn.column_name").innerHTML = this.get_column_title(ColumnName); this.$obj(this.control_name + ".edit.column.row_value").innerHTML = row; this.$obj(this.control_name + ".edit.column.data_type").innerHTML = this.dt.getFieldTypeByName(ColumnName); try { this.oGDD = new GrabDragDropClass(); this.oGDD.initialize(str_target_name, str_trigger_name, "", ""); } catch (e) { alert("this.oGDD = new GrabDragDropClass(); 發生錯誤"); } //設定 文字輸入框 的 『自動改變大小功能』 //function textarea_resize(obj_name, min_col, max_col, min_row, max_row) textarea_resize(str_textbox_name, 10, 80, 4, 40); set_element_value(str_textbox_name , ColumnValue ); set_element_value(this.control_name + ".edit.column.row" , row ); set_element_event(this.control_name + ".edit.column.cancel" , "onclick" , function () { hide_div(display_edit_column); } ); set_element_value(this.control_name + ".edit.column.confirm" , this.edit_column_btn_name_confirm ); set_element_value(this.control_name + ".edit.column.cancel" , this.edit_column_btn_name_cancel ); //設定 資料編輯確認 按鈕 事件 set_element_event(this.control_name + ".edit.column.confirm" , "onclick" , function () { try { var _value = get_element_value(str_textbox_name); if (the_dg.setValue_before(row, ColumnName, _value) == false) return (false); if (the_dg.flg_auto_update == 1) { //alert("the_dg.flg_auto_update = " + the_dg.flg_auto_update); if (the_dg.on_setValue(row, ColumnName, _value) == false) return (false); the_dg.setValue(row, ColumnName, _value); } else { the_dg.setValue(row, ColumnName, _value); the_dg.refresh(); } hide_div(display_edit_column); } catch (e) { alert(the_dg.control_name + " 『資料編輯 確認』錯誤!" + "\n錯誤訊息:" + e.Message ); return (false); } } ); set_element_focus(str_textbox_name); this.$ele(str_textbox_name)[0].onkeydown(); } this.setValue = function (row, ColumnName, value) { try { this.dt.setValueByRow(row, ColumnName, value); } catch (e) { alert("this.dt.setValueByRow(" + row + ", " + ColumnName + ", " + value + ") 發生錯誤 : " + "\n錯誤訊息:" + e.Message ); return (false); } } this.on_setValue = function (row, ColumnName, value) { var dt = new DataTable(); var str_csv_format = new StringBuilder(); var str_id = this.dt.getValueByRow(row, "id") var str_xml_data = ""; with(str_csv_format) { Append("\n" + "0,id,type,name,value,memo"); Append("\n" + "1,System.String,System.String,System.String,System.String,System.String"); Append("\n" + "2,1,KeyValue,id,,欄位Key值"); Append("\n" + "2,2,ColumnValue,,,要準備對資料庫更新的欄位以及欄位值"); Append("\n"); } //alert(str_csv_format.ToString()); with (dt) { ImportCSV(str_csv_format.ToString()); setValueByIndex("id", "1", "value", str_id); setValueByIndex("id", "2", "name", ColumnName); setValueByIndex("id", "2", "value", value); } str_xml_data = dt.ExportXML("UpdateData", "UpdateColumn", "", 0, -1); set_element_value("XML", str_xml_data); try { var str_url = this.str_page_name + "?AJAX=1&do_action=ajax_update_data"; var str_element_list = "XML"; var str_result = ""; str_result = dt.connect(str_url, str_element_list); if (dt.getValue("flg_error") == "1") { alert("資料更新失敗!\n" + dt.getValue("message")); return (false); } else { this.setValue_after(); return (true); } } catch (e) { window.status = "DataGrid.on_setValue() 發生錯誤!" + "\n錯誤訊息:" + e.Message + "\n終止程式執行"; return (false); } } this.setValue_before = function () { } this.setValue_after = function () { } this.data_delete = function (row) { var str_url = ""; var str_element_list = ""; var row_id = this.dt.getValueByRow(19, "id"); var dt = new DataTable(); if (this.data_delete_before() == false) return (false); //if (this.dt.getValueByRow(row, "001hours") != "0" || this.dt.getValueByRow(row, "001hours")!="") //{ // alert("此加班轉補休已被使用,無法刪除修改。請洽系統人員!!"); // o_AddNewForm.active == 1; // // return (true); //} // if (row_id == "") { if (confirm("是否確定刪除這筆資料?")) this.delete_row(row); this.data_delete_after(); return (false); } if (confirm("是否確定刪除這筆資料?") == false) return (false); try { str_url = this.str_page_name + "?AJAX=1&do_action=ajax_data_delete&id=" + row_id; dt.connect(str_url, str_element_list); if (dt.getValue("flg_error") == "1") { alert(dt.getValue("message")); return (false); } else { this.data_delete_after(); return (false); } } catch (e) { window.status = "DataGrid.data_delete() 發生錯誤" + "\n id = " + row_id + "\n 錯誤訊息:" + e.Message; return (false); } } this.data_delete_before = function () { } this.data_delete_after = function () { } this.data_edit = function (row) { //alert("此加班轉補休已被使用,無法刪除修改。請洽系統人員!!"); //return (false); window.status = "目前沒有設定功能!"; } this.initialize = function () { } this.create_textbox2 = function (dt_row, _name, _value) { var element_param = ""; var dt = this.schema_dt; var row = dt.Search("NAME", _name); var _display_content = ""; var str_NOT_NULL = dt.getValueByRow(row, "NOT_NULL"); var str_NUMERIC = dt.getValueByRow(row, "NUMERIC"); var str_TYPE = dt.getValueByRow(row, "TYPE"); var str_DECIMAL = dt.getValueByRow(row, "DECIMAL"); var element_name = dt.getValueByRow(row, "ELE_NAME"); var str_LEN = dt.getValueByRow(row, "LEN"); // var str_display_name = this.str_display_name; if (element_param == "") { switch (str_TYPE.toUpperCase()) { case "String".toUpperCase(): element_param = "size='%len%' maxlength='%len%'"; element_param = element_param.ReplaceAll("%len%", str_LEN); break; case "Numeric".toUpperCase(): var _length = parseInt(str_LEN, 10); if (str_DECIMAL != "" && str_DECIMAL != "0") _length += 1; element_param = "size='%len%' maxlength='%len%' STYLE='text-align:right'"; element_param = element_param.ReplaceAll("%len%", _length); break; case "Integer".toUpperCase(): element_param = "size='%len%' maxlength='%len%' STYLE='text-align:right'"; element_param = element_param.ReplaceAll("%len%", str_LEN); break; case "Date".toUpperCase(): element_param = "size='%len%' maxlength='%len%'"; element_param = element_param.ReplaceAll("%len%", "8"); break; case "Time".toUpperCase(): element_param = "size='%len%' maxlength='%len%'"; element_param = element_param.ReplaceAll("%len%", "5"); break; case "DateTime".toUpperCase(): element_param = "size='20' maxlength='20'"; break; default: element_param = "size='20' maxlength='20'"; break; } var element_disabled = dt.getValueByRow(row, "ELE_DISABLED"); if (str_NOT_NULL == "1" && element_disabled != "1") { element_param += " style=\"border-color:red\""; } } //str_display_name = str_display_name.ReplaceAll("%namespace%", this.str_namespace); //str_display_name = str_display_name.ReplaceAll("%FormName%", this.str_form_name); //str_display_name = str_display_name.ReplaceAll("%EleName%", element_name); _display_content = ""; // Detail 新增 _display_content += " "; if (str_TYPE.toUpperCase() == "Date".toUpperCase() && element_disabled != "1") { _display_content += "   "; var mouseover = ""; mouseover += "Calendar.setup("; mouseover += " {"; mouseover += " inputField : \"%name%\","; mouseover += " ifFormat : \"%Y%m%d\","; mouseover += " button : \"%name%.img\" "; mouseover += " }"; mouseover += ");" //mouseover += "style=\"cursor:Hand;\""; _display_content = _display_content.ReplaceAll("%onmouseover%", mouseover); _display_content = _display_content.ReplaceAll("%company_code%", COMPANY_CODE); } element_param += " VALUE='" + _value + "'"; element_param += " onblur=\"JavaScript:%ControlName%.td_onblur(%row%, '%ColumnName%', this.value);\""; element_param = element_param.ReplaceAll("%row%", dt_row-1); element_param = element_param.ReplaceAll("%ColumnName%", _name); element_param = element_param.ReplaceAll("%ControlName%", this.control_name); _display_content = _display_content.ReplaceAll("%name%", element_name + "_" + dt_row.toString()); _display_content = _display_content.ReplaceAll("%param%", element_param); return (_display_content); } this.td_onblur = function (row, _name, _value) { if (this.td_after_onblur(row, _name, _value)) this.setValue(row, _name, _value); }; this.td_after_onblur = function (row, _name, _value) { return true; }; this.before_display_value = function(dt,buf,FieldName,_value) { }; } -->