Beispiel #1
0
        /// <summary>
        /// 表格行中模板列控件列表(数据绑定时自动生成每个模板列控件ID,回发时从FState中回发模板列控件ID)
        /// </summary>
        public void InitTemplateContainers()
        {
            Collection <GridColumn> columns = _grid.AllColumns;

            TemplateContainers = new GridTemplateContainer[columns.Count];

            for (int i = 0, count = columns.Count; i < count; i++)
            {
                GridColumn column = columns[i];
                if (column is TemplateField)
                {
                    TemplateField         field   = column as TemplateField;
                    GridTemplateContainer control = new GridTemplateContainer(DataItem, RowIndex);


                    // 不用指定ID,会自动生成类似 ct123 的唯一ID
                    //control.ID = String.Format("c{0}r{1}", column.ColumnIndex, RowIndex);

                    if (DataItem == null)
                    {
                        // 回发时恢复FState阶段(非数据绑定阶段),从Values中读取模板列的服务器ID(在第一次加载时自动生成的)
                        string fieldValue = Values[i].ToString();
                        if (fieldValue.StartsWith(Grid.TEMPLATE_PLACEHOLDER_PREFIX))
                        {
                            control.ID = fieldValue.Substring(Grid.TEMPLATE_PLACEHOLDER_PREFIX.Length);
                        }
                    }



                    field.ItemTemplate.InstantiateIn(control);

                    _grid.Controls.Add(control);
                    TemplateContainers[column.ColumnIndex] = control;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 表格行中模板列控件列表(数据绑定时自动生成每个模板列控件ID,回发时从FState中回发模板列控件ID)
        /// </summary>
        public void InitTemplateContainers()
        {
            Collection<GridColumn> columns = _grid.AllColumns;
            TemplateContainers = new GridTemplateContainer[columns.Count];

            for (int i = 0, count = columns.Count; i < count; i++)
            {
                GridColumn column = columns[i];
                if (column is TemplateField)
                {
                    TemplateField field = column as TemplateField;
                    GridTemplateContainer control = new GridTemplateContainer(DataItem, RowIndex);
                    

                    // 不用指定ID,会自动生成类似 ct123 的唯一ID
                    //control.ID = String.Format("c{0}r{1}", column.ColumnIndex, RowIndex);

                    if (DataItem == null)
                    {
                        // 回发时恢复FState阶段(非数据绑定阶段),从Values中读取模板列的服务器ID(在第一次加载时自动生成的)
                        string fieldValue = Values[i].ToString();
                        if (fieldValue.StartsWith(Grid.TEMPLATE_PLACEHOLDER_PREFIX))
                        {
                            control.ID = fieldValue.Substring(Grid.TEMPLATE_PLACEHOLDER_PREFIX.Length);
                        }
                    }

                    

                    field.ItemTemplate.InstantiateIn(control);

                    _grid.Controls.Add(control);
                    TemplateContainers[column.ColumnIndex] = control;


                }

            }
        }
Beispiel #3
0
        internal override object GetColumnValue(GridRow row)
        {
            GridTemplateContainer control = row.TemplateContainers[ColumnIndex];

            return(String.Format("{0}{1}", Grid.TEMPLATE_PLACEHOLDER_PREFIX, control.ID));
        }