table").width(w - 50);
$j("[id='" + that.data.target_name + "']").dialog( "option", "position", ['center','top'] );
}
, form : {
str_form_namespace : "display.AddNew.form"
, str_form_name : "CMA001_AddNewForm"
, str_template_name : "AddNewForm.htm"
, str_template_no_new_line : ""
, str_template_with_head : ""
, str_template_no_td : ""
, str_template_no_head : ""
, str_form_template : ""
, str_template_heading : ""
, str_schema_name : "AddNewForm.xml"
, display_name : "display.AddNew.form"
, display_detail_name : "display.AddNewDetail.form" // added by thomas for detail
, o_dg : new DataGridExp()
, o_detail_dgs : [] // added by thomas for detail
, o_Form : new clsForm()
, dt_schema : new DataTable()
, dt_detail_schemas : [] // added by thomas for detail
, detail : 0 // added by thomas for detail 是否有 detail 表單
, _created : 0
, create : function ()
{
if (that.data._opened == 0 && that.data.delay_init == 1) return;
this.get_template();
this.get_schema();
with (this.o_dg)
{
flg_show_html = 1;
flg_auto_breakline = 0;
max_cols = 1000;
dt = this.dt_schema;
str_template = this.str_form_template;
str_template_no_new_line = this.str_template_no_new_line;
str_template_with_head = this.str_template_with_head;
str_template_no_td = this.str_template_no_td;
str_template_no_head = this.str_template_no_head ;
str_template_heading = this.str_template_heading ;
get_field_list();
$(this.display_name).innerHTML = GetDataGrid();
}
if (this.detail == 1) // added by thomas for detail
{
}
with (this.o_Form)
{
functions = g_functions;
dt = this.dt_schema;
str_namespace = this.str_form_namespace;
str_form_name = this.str_form_name;
check_detaildata = that.data.check_detaildata;
create_form();
if (this.detail == 1) // added by thomas for detail
{
this.o_detail_dgs = [];
var oldTABS = TABS;
TABS = [];
for (var i = 0; i < that.data.details_all.length; i++)
{
var index = that.data.details_all[i].index;
if ( that.data.details_all[i].delay_create == 0) {
this.o_detail_dgs[index] = new DataGridExp();
with (this.o_detail_dgs[index])
{
flg_show_html = 1;
flg_auto_breakline = 0;
max_cols = 1000;
var old_dt = dt;
dt = this.dt_detail_schemas[index];
dt_detail = this.dt_detail_schemas[index];
if (that.data.form.str_template_name != that.data.details_all[i].AddNew_template_name)
{
str_template = o_Page.get_template(that.data.details_all[i].AddNew_template_name);
str_template = str_template.ReplaceAll("%namespace%", that.data.form.str_form_namespace);
str_template = str_template.ReplaceAll("%FormName%", that.data.form.str_form_name);
}
else
str_template = that.data.form.str_form_template;
// str_template = this.str_form_template;
str_template_no_new_line = this.str_template_no_new_line;
str_template_with_head = this.str_template_with_head;
str_template_no_td = this.str_template_no_td;
str_template_no_head = this.str_template_no_head ;
str_template_heading = this.str_template_heading ;
get_field_list();
if ( $(that.data.details_all[i]) != null) {
$(that.data.details_all[i].AddNew_display_name).innerHTML = GetDataGrid();
create_form();
that.data.details_all[i].AddNew_form_created = 1 ;
}
dt = old_dt;
}
}
}
TABS = oldTABS;
}
}
this.form_after_create();
that.data.form._created = 1;
}
,form_after_create : function() {}
, get_schema : function ()
{
// modified for detail
this.dt_schema = o_Page.get_schema_byNameSpace(this.str_schema_name,"AddNew");
this.dt_detail_schemas = [];
for (var i = 0; i < that.data.details.length; i++)
{
this.dt_detail_schemas[i] = new DataTable()
this.dt_detail_schemas[i] = o_Page.get_schema_byNameSpace(this.str_schema_name,that.data.details[i].AddNew_prefix); // added by thomas for detail
for (var o = 0; o < that.data.details[i].child_details.length; o++) {
this.dt_detail_schemas[i + "L3" + o] = new DataTable();
this.dt_detail_schemas[i + "L3" + o] = o_Page.get_schema_byNameSpace(this.str_schema_name,that.data.details[i].child_details[o].AddNew_prefix); // added by thomas for detail
}
}
if (this.dt_detail_schemas.length > 0)
if (this.dt_detail_schemas[0].MaxRow() > 0) this.detail = 1; // added by thomas for detail
}
, get_template : function ()
{
this.str_form_template = o_Page.get_template(this.str_template_name);
this.str_form_template = this.str_form_template.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_form_template = this.str_form_template.ReplaceAll("%FormName%", this.str_form_name);
this.str_template_no_head = " %namespace%.%FormName%.%ELE_NAME% |
" ;
this.str_template_no_td = " %namespace%.%FormName%.%ELE_NAME% "
this.str_template_no_new_line = " %namespace%.%FormName%.%ELE_NAME% | "
this.str_template_with_head = " %TITLE% | " + this.str_template_no_new_line
this.str_template_heading = " %TITLE% | "
this.str_template_no_td = this.str_template_no_td.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_template_no_td = this.str_template_no_td.ReplaceAll("%FormName%", this.str_form_name);
this.str_template_no_new_line = this.str_template_no_new_line.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_template_no_new_line = this.str_template_no_new_line.ReplaceAll("%FormName%", this.str_form_name);
this.str_template_with_head = this.str_template_with_head.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_template_with_head = this.str_template_with_head.ReplaceAll("%FormName%", this.str_form_name);
this.str_template_no_head = this.str_template_no_head.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_template_no_head = this.str_template_no_head.ReplaceAll("%FormName%", this.str_form_name);
this.str_template_heading = this.str_template_heading.ReplaceAll("%namespace%", this.str_form_namespace);
this.str_template_heading = this.str_template_heading.ReplaceAll("%FormName%", this.str_form_name);
}
, set_message : function (ele_name, str)
{
this.o_Form.set_message(ele_name, str);
}
, refresh_listbox : function(ele_name, row_no)
{
with (this.o_Form)
{
is_list_cached = false;
dt = this.dt_schema;
if (ele_name.indexOf("Detail") > 0) {
var e = ele_name.split(".");
var i = e[0].substr(e[0].length - 1, 1);
var index = (i == "l" ? 0 : parseInt(i, 10));
if (that.data.details[index].master_detail_style == 0) {
var old_dt2 = dt;
dt = this.dt_detail_schemas[index];
refresh_listbox(ele_name,"Y");
dt = old_dt2;
is_list_cached = true;
return ;
}
}
if (!refresh_listbox(ele_name,"Y"))
{
var old_dt2 = dt;
var e = ele_name.split(".");
var i = e[0].substr(e[0].length - 1, 1);
var index = (i == "l" ? 0 : parseInt(i, 10));
is_list_cached = true;
dt = this.dt_detail_schemas[index];
refresh_listbox(ele_name, "D", row_no);
dt = old_dt2;
}
is_list_cached = true;
}
}
, set_Tab : function()
{
if (TABS == "undefined") return;
if (TABS.length > 0)
{
showTab("AddNew." + TABS[0]);
}
}
}
}
}