/// <summary> /// 设置Store /// </summary> /// <returns></returns> private string GetDataGridStore() { SearchMultiSelect control = (SearchMultiSelect)this.ControlHost.Content; StringBuilder result = new StringBuilder(); bool bindingDataSource = false; Dictionary <string, string> dictProperty = control.GetPropertyBindValue(); if (!IsPreview && control.Bindings.Count > 0) { foreach (var item in control.Bindings) { string bindPath = item.Path == null ? "" : item.Path; string bindProperty = item.Property == null ? "" : item.Property; if (bindProperty.ToLower() == "datasource") { string property = string.Empty; if (dictProperty.ContainsKey(bindProperty)) { if (dictProperty.TryGetValue(bindProperty, out property)) { bindProperty = property; } } if (!string.IsNullOrEmpty(bindPath) && !string.IsNullOrEmpty(bindProperty)) { result.AppendFormat("at('rel:{0}', '{1}').direction(1),", "", bindPath); if (bindProperty.ToLower() == "datasource") { bindingDataSource = true; } } } } } if (!IsPreview && control.ExistProperty("DataSource") && !bindingDataSource) { string bindPath = control.DataSource; string bindProperty = "DataSource"; if (!string.IsNullOrEmpty(bindPath)) { string property = string.Empty; if (dictProperty.ContainsKey(bindProperty)) { if (dictProperty.TryGetValue(bindProperty, out property)) { bindProperty = property; } } result.AppendFormat("at('rel:{0}', '{1}').direction(1),", "", bindPath); } } return(result.ToString().Length == 0 ? "" : result.ToString().Substring(0, result.Length - 1)); }
/// <summary> /// 设置属性 /// </summary> protected override void SetAttributes() { SearchMultiSelect control = this.ControlHost.Content as SearchMultiSelect; this.HtmlWriter.AddAttribute("dojoType", "Controls/CheckedMultiSelect2"); if (!IsPreview && !string.IsNullOrEmpty(this.ControlHost.Name)) { this.HtmlWriter.AddAttribute("id", this.ControlHost.Name); this.HtmlWriter.AddAttribute("name", this.ControlHost.Name); } if (!string.IsNullOrEmpty(control.ToolTip) && this.ProjectDocument != null) { this.HtmlWriter.AddAttribute("tooltip-name", this.ProjectDocument.Name + "_" + control.ToolTip); } this.HtmlWriter.AddAttribute("dropdown", "true"); this.HtmlWriter.AddAttribute("multiple", "true"); this.HtmlWriter.AddAttribute("required", "false"); string stores = GetDataGridStore(); if (!string.IsNullOrEmpty(stores)) { this.HtmlWriter.AddAttribute("store", stores, false); } StringBuilder sbProps = new StringBuilder(); StringBuilder returnContent = new StringBuilder(); string props = control.BuildControlProps(this.ScreenDefinition, this.IsPreview, this.PermissionData, returnContent); if (!string.IsNullOrEmpty(props)) { sbProps.AppendFormat("{0},", props); } sbProps.AppendFormat("{0},", "maxHeight:200"); if (!IsPreview) { sbProps.AppendFormat("{0},", "showSearch:" + control.ShowSearch.ToString().ToLower() + ""); } if (sbProps.ToString().Length > 0) { this.HtmlWriter.AddAttribute("data-dojo-props", sbProps.ToString().Substring(0, sbProps.ToString().Length - 1), false); } base.SetAttributes(); }