確定刪除?";
var str_iGuid = that.data.str_iGuid;
var dt_send = new DataTable();
var str_xml = "";
if (that.data.before_delete_data() == false)
return (false);
str_message += "\n\n";
var grid = getGrid();
for (var i = 1; i < grid.columns.length; i++) {
if (i >= 10) break;
if (typeof(grid.columns[i].field) == "undefined") continue;
var str_buf = "\n%title%:%value%";
var str_value = that.data.dt_data.getValue(grid.columns[i].field);
str_buf = str_buf.ReplaceAll("%title%", grid.columns[i].title);
str_buf = str_buf.ReplaceAll("%value%", str_value);
str_message += str_buf;
}
jconfirm(str_message, "確認", function (result) { if (result) that.data.delete_action(); })
}
, delete_action : function () {
var item = ds.get(that.data.iGuid);
if ( that.data.form.detail == 1)
{
// 放入 master_detail_key list 到 __dt_key
item.set("__dt_key", that.data.master_detail_key_list);
}
that.data.delete_rowno = parseInt(item._row_no, 10);
that.data.delete_rowno -= 1;
if (that.data.delete_rowno <= 0) that.data.delete_rowno = 1;
getGrid().dataSource.remove(ds.get(that.data.iGuid));
that.data.data_source.one("sync",o_EditForm._after_save);
getGrid().dataSource.sync();
}
, before_delete_data : function ()
{
}
, after_delete_data : function ()
{
}
, check_detaildata : function (detail_row, name, element_name, value )
{
}
, set_width : function (w) {
$j("[id='" + that.data.target_name + "']").dialog("option", "width",w );
$j("[id='" + that.data.target_name + "']>table").width(w - 50);
// $j("[id='" + that.data.target_name + "']").dialog( "option", "position", ['center','top'] );
}
, form : {
str_form_namespace : "display.Edit.form"
, str_form_name : "CMA001_EditForm"
, str_template_name : "EditForm.htm"
, str_form_template : ""
, str_template_no_new_line : ""
, str_template_with_head : ""
, str_template_no_td : ""
, str_template_no_head : ""
, str_template_heading : ""
, str_schema_name : "EditForm.xml"
, display_name : "display.Edit.form"
, display_detail_name : "display.EditDetail.form" // added by thomas for detail
, o_dg : new DataGridExp()
, o_detail_dgs : [] // added by thomas for detail
, o_Form : new clsForm()
, dt_schemas : []
, dt_detail_schemas : [] // added by thomas for detail
, detail : 0 // added by thomas for detail 是否有 detail 表單
// , dt_schema : new DataTable()
, _created : 0
, create : function ()
{
if (that.data._opened == 0 && that.data.delay_init == 1) return;
that.data.form.get_template();
that.data.form.get_schema();
with (that.data.form.o_dg)
{
flg_show_html = 1;
flg_auto_breakline = 0;
max_cols = 1000;
dt = that.data.dt_schema;
str_template = that.data.form.str_form_template;
str_template_no_new_line = that.data.form.str_template_no_new_line;
str_template_with_head = that.data.form.str_template_with_head;
str_template_no_td = that.data.form.str_template_no_td;
str_template_no_head = that.data.form.str_template_no_head ;
str_template_heading = that.data.form.str_template_heading ;
get_field_list();
if (that.data.server_content == 1) {
// $j.ajax({ async:false, url: "resource/EditContent.htm", dataType:"html", cache :true, success: function (data) { $(that.data.form.display_name).innerHTML = data;} });
}
else
$(that.data.form.display_name).innerHTML = GetDataGrid();
}
with (that.data.form.o_Form)
{
dt = that.data.dt_schema;
str_namespace = that.data.form.str_form_namespace;
str_form_name = that.data.form.str_form_name;
str_template_no_new_line = that.data.form.str_template_no_new_line;
check_detaildata = that.data.form.check_detaildata;
create_form();
if (that.data.form.detail == 1) // added by thomas for detail
{
that.data.o_detail_dgs = [];
var oldTABS = TABS;
TABS = [];
for (var i = 0; i < that.data.details.length; i++)
{
if ( that.data.details[i].delay_create == 0) {
that.data.o_detail_dgs[i] = new DataGridExp();
with (that.data.o_detail_dgs[i])
{
flg_show_html = 1;
flg_auto_breakline = 0;
max_cols = 1000;
var old_dt = dt;
dt = that.data.form.dt_detail_schemas[i];
dt_detail = that.data.form.dt_detail_schemas[i];
if (that.data.form.str_template_name != that.data.details[i].Edit_template_name)
{
str_template = o_Page.get_template(that.data.details[i].Edit_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_no_new_line = that.data.form.str_template_no_new_line;
str_template_with_head = that.data.form.str_template_with_head;
str_template_no_td = that.data.form.str_template_no_td;
str_template_no_head = that.data.form.str_template_no_head ;
str_template_heading = that.data.form.str_template_heading ;
get_field_list();
$( that.data.details[i].Edit_display_name).innerHTML = GetDataGrid();
dt = old_dt;
}
}
TABS = oldTABS;
}
for (var i = 0; i < that.data.details.length; i++) {
if ( that.data.details[i].delay_create == 0) {
var old_dt2 = dt;
dt = that.data.form.dt_detail_schemas[i];
create_form();
that.data.details[i].form_created = 1;
dt = old_dt2;
}
}
}
that.data.form._created = 1;
}
}
, get_schema : function ()
{
that.data.dt_schema = o_Page.get_schema_byNameSpace(that.data.form.str_schema_name,"Edit");
for (var i = 0; i < that.data.details.length; i++)
{
that.data.form.dt_detail_schemas[i] = new DataTable()
that.data.form.dt_detail_schemas[i] = o_Page.get_schema_byNameSpace(that.data.form.str_schema_name,that.data.details[i].Edit_prefix); // added by thomas for detail
}
if (that.data.form.dt_detail_schemas.length > 0)
if (that.data.form.dt_detail_schemas[0].MaxRow() > 0) that.data.form.detail = 1; // added by thomas for detail
}
, get_template : function ()
{
with (that.data.form) {
str_form_template = o_Page.get_template(str_template_name);
str_form_template = str_form_template.ReplaceAll("%namespace%", str_form_namespace);
str_form_template = str_form_template.ReplaceAll("%FormName%", str_form_name);
str_template_no_td = " %namespace%.%FormName%.%ELE_NAME% "
str_template_no_new_line = " %namespace%.%FormName%.%ELE_NAME% | "
str_template_with_head = " %TITLE% | " + str_template_no_new_line
str_template_no_head = " %namespace%.%FormName%.%ELE_NAME% |
" ;
str_template_no_td = str_template_no_td.ReplaceAll("%namespace%", str_form_namespace);
str_template_no_td = str_template_no_td.ReplaceAll("%FormName%", str_form_name);
str_template_no_new_line = str_template_no_new_line.ReplaceAll("%namespace%", str_form_namespace);
str_template_no_new_line = str_template_no_new_line.ReplaceAll("%FormName%", str_form_name);
str_template_heading = " %TITLE% | "
str_template_with_head = str_template_with_head.ReplaceAll("%namespace%", str_form_namespace);
str_template_with_head = str_template_with_head.ReplaceAll("%FormName%", str_form_name);
str_template_no_head = str_template_no_head.ReplaceAll("%namespace%", str_form_namespace);
str_template_no_head = str_template_no_head.ReplaceAll("%FormName%", str_form_name);
str_template_heading = str_template_heading.ReplaceAll("%namespace%", this.str_form_namespace);
str_template_heading = str_template_heading.ReplaceAll("%FormName%", this.str_form_name);
}
}
, refresh_listbox : function(ele_name, row_no)
{
with (that.data.form)
{
is_list_cached = false;
dt = that.data.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 = that.data.form.o_Form.dt;
that.data.form.o_Form.dt = dt_detail_schemas[index];
that.data.form.o_Form.refresh_listbox(ele_name,"Y");
that.data.form.o_Form.dt = old_dt2;
is_list_cached = true;
return ;
}
}
if (!that.data.form.o_Form.refresh_listbox(ele_name,"Y"))
{
var old_dt2 = that.data.form.o_Form.dt;
is_list_cached = true;
var e = ele_name.split(".");
var i = e[0].substr(e[0].length - 1, 1);
var index = (i == "l" ? 0 : parseInt(i, 10));
that.data.form.o_Form.dt = dt_detail_schemas[index];
that.data.form.o_Form.refresh_listbox(ele_name, "D", row_no);
that.data.form.o_Form.dt = old_dt2;
}
is_list_cached = true;
}
}
, set_Tab : function()
{
if (TABS == "undefined") return;
if (TABS.length > 0)
{
showTab("Edit." + TABS[0]);
}
}
}
}
}