// aw = aw //private static readonly string ACTIVE_WINDOW_SCRIPT = "if(!aw){var aw=parent.window.X.window_default_group.getActive();}"; //private static readonly string ACTIVE_WINDOW_SCRIPT = "var parentClientID=box_getParentClientIdFromUrl();if(parentClientID){var window2=parent.window;var aw=parent.window.Ext.getCmp(parentClientID);if(aw.box_property_frame_element_name){window2=parent.Ext.query('iframe[name='+aw.box_property_frame_element_name+']')[0].contentWindow;aw=eval('window2.X.'+aw.id);}}"; //private static readonly string ACTIVE_WINDOW_SCRIPT = "var aw=X.wnd.getActiveWindow();"; #endregion #region GetWriteBackValueReference /// <summary> /// 获取将values值写回控件的客户端脚本 /// </summary> /// <param name="values">需要写回的字符串列表</param> /// <returns>客户端脚本</returns> public static string GetWriteBackValueReference(params string[] values) { #region old code //// 去除重复的 ACTIVE_WINDOW_SCRIPT //if (controlClientIds.Contains(ACTIVE_WINDOW_SCRIPT)) //{ // controlClientIds = controlClientIds.Replace(ACTIVE_WINDOW_SCRIPT, ""); //} //// 此时 controlClientId 是个字符串 或者是 是个字符串的数组,里面是需要赋值的文本框的ClientID //StringBuilder sb = new StringBuilder(); //sb.Append(ACTIVE_WINDOW_SCRIPT); //sb.AppendFormat("var controlClientIds={0};", controlClientIds); //sb.AppendFormat("if(typeof(controlClientIds)=='string'){{{0}}}", "aw[1].Ext.getCmp(controlClientIds).setValue(" + JsHelper.Enquote(value) + ");"); //// values //StringBuilder valuesBuilder = new StringBuilder(); //if (values.Length > 0) //{ // valuesBuilder.AppendFormat("var controlValues={0};", JsHelper.GetJsStringArray(values)); // valuesBuilder.Append("var controlCount=Math.min(controlClientIds.length-1,controlValues.length);"); // valuesBuilder.AppendFormat("for(var i=0;i<controlCount;i++){{{0}}}", "aw[1].Ext.getCmp(controlClientIds[i+1]).setValue(controlValues[i]);"); //} //sb.AppendFormat("else{{{0}{1}}}", "aw[1].Ext.getCmp(controlClientIds[0]).setValue(" + JsHelper.Enquote(value) + ");", valuesBuilder.ToString()); //return sb.ToString(); #endregion return(String.Format("X.wnd.writeBackValue.apply(window,{0});", JsHelper.GetJsStringArray(values))); }