Exemple #1
0
        public virtual void ColumnsForAll(string modelConfigName)
        {
            var cs = new PFGridColumnCollection {
                Grid = this
            };

            if (!string.IsNullOrWhiteSpace(modelConfigName))
            {
                cs.SetModelConfig(modelConfigName);
            }

            if (_model != null && _model.Count > 0)
            {
                if (_model[0] is TreeListItem)
                {
                    PFDataHelper.EachObjectProperty((_model[0] as TreeListItem).Data, (i, name, value) =>
                    {
                        ////旧版只有一句?待验证--benjamin todo 20191014
                        //cs.Add(name);

                        var c = cs.Add(name);
                        if (value != null)
                        {
                            PFGridColumn.SetStyleByDataType(c, value.GetType());
                        }
                    });
                }
                else if (_model[0] is Dictionary <string, object> )//新版才有这段代码?待验证--benjamin todo 20191014
                {
                    var dict = (_model[0] as Dictionary <string, object>);
                    foreach (var key in dict.Keys)
                    {
                        var c     = cs.Add(key);
                        var value = dict[key];
                        if (value != null)
                        {
                            PFGridColumn.SetStyleByDataType(c, value.GetType());
                        }
                    }
                }
            }
            cs.ForEach(_columns.Add);
        }