Пример #1
0
        public static List <ExtGridColumn> GetListColumns(IList <PbBaseTextInfo> pbcontrols)
        {
            SortedList <int, PbBaseControlInfo> list = new SortedList <int, PbBaseControlInfo>();
            List <ExtGridColumn> columns             = new List <ExtGridColumn>();

            foreach (PbBaseControlInfo item in pbcontrols)
            {
                if (list.ContainsKey(item.XPos))    //如果x坐标重复,则跳过 //0000000038 这里有重复的
                {
                    continue;
                }
                list.Add(item.XPos, item);//以x坐标排序
            }

            foreach (KeyValuePair <int, PbBaseControlInfo> element in list)
            {
                PbBaseTextInfo textInfo = element.Value as PbBaseTextInfo;

                if (textInfo != null)
                {
                    ExtGridColumn col = new ExtGridColumn();
                    if (textInfo.Name.Equals("t_sum"))
                    {
                        continue;
                    }
                    col.Header          = textInfo.LeftText;
                    col.DataIndex       = textInfo.Name;
                    col.Datatype        = SqlTypeConverter.ConvertToExtControl(textInfo.ColumnInfo.ColumnDataType);
                    col.DefaultValue    = textInfo.DefaultValue;
                    col.Width           = textInfo.Width;                                    //Grid每一列的宽度
                    col.RgbColor        = ControlConverter.GetRgb(textInfo.Color);           //grid列的字体颜色
                    col.BackgroundColor = ControlConverter.GetRgb(textInfo.backgroundColor); //grid列的背景颜色

                    ExtControlBase column = ControlConverter.ConvertToExtControl(textInfo);  //转换下xtype的类型;
                    col.Protect      = column.Protect;
                    col.MustInput    = column.MustInput;
                    col.Format       = column.Format;
                    col.EditMask     = column.EditMask;
                    col.editor.XType = column.XType;


                    if (col.editor.XType == "ngCustomFormHelp" || col.editor.XType == "ngRichHelp")
                    {
                        var temp = column as NGHelpBase;
                        if (temp.Helpid == "itemdata")
                        {
                            col.DataIndex            = "itemid";
                            col.Header               = "物资";
                            col.editor.ValueField    = "phid";
                            col.editor.DisplayField  = "itemname";
                            col.editor.ListFields    = "itemid,c_name,spec,msname";
                            col.editor.ListHeadTexts = "编码,名称,规格,单位";
                            col.editor.Helpid        = temp.Helpid;
                        }
                        else
                        {
                            col.editor.ValueField    = temp.ValueField;
                            col.editor.DisplayField  = temp.DisplayField;
                            col.editor.ListFields    = temp.ListFields;
                            col.editor.ListHeadTexts = temp.ListHeadTexts;
                            col.editor.CmpName       = temp.CmpName;
                            col.editor.OutFilter     = temp.OutFilter;
                            col.editor.Helpid        = temp.Helpid;
                            col.editor.MultiSelect   = temp.MultiSelect;
                        }
                    }
                    else if (col.editor.XType == "ngComboBox")
                    {
                        if (column is NGComboBox)
                        {
                            NGComboBox temp = column as NGComboBox;
                            col.editor.QueryMode = temp.QueryMode;
                            col.editor.Data      = temp.Data;
                        }
                        else if (column is NGCommonHelp)
                        {
                            NGCommonHelp temp = column as NGCommonHelp;
                            col.editor.QueryMode = temp.QueryMode;
                            col.editor.Data      = temp.Data;
                        }
                    }
                    else if (col.editor.XType == "ngRadio")
                    {
                        var temp = column as NGRadio;
                        col.editor.Items = temp.Items;
                    }

                    columns.Add(col);
                }
            }

            return(columns);
        }