示例#1
0
        /// <summary>
        /// 设置TreeGrid的Store
        /// </summary>
        /// <returns></returns>
        private string GetStore()
        {
            TreeGrid control = this.ControlHost.Content as TreeGrid;

            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("store: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("store:at('rel:{0}', '{1}').direction(1),", "", bindPath);
                }
            }

            return(result.ToString());
        }