internal void FromShortStates(object[] shortStates) { GridColumnCollection columns = _grid.AllColumns; States = new object[columns.Count]; int shortStateIndex = 0; for (int i = 0, count = columns.Count; i < count; i++) { GridColumn column = columns[i]; if (column.PersistState) { object state = shortStates[shortStateIndex++]; //Values[i] = column.GetColumnValue(this); if (state is JValue) { States[i] = (state as JValue).Value; } else { States[i] = state; } } } }
//private object[] _extraValues = null; ///// <summary> ///// 附加要保存的值(比如CheckBoxField需要保存是否选中的状态) ///// </summary> //internal object[] ExtraValues //{ // get // { // return _extraValues; // } // set // { // _extraValues = value; // } //} #endregion #region ToShortStates/FromShortStates internal object[] ToShortStates() { List <object> shortStates = new List <object>(); GridColumnCollection columns = _grid.AllColumns; for (int i = 0, count = columns.Count; i < count; i++) { if (columns[i].PersistState) { shortStates.Add(States[i]); } } return(shortStates.ToArray()); }
/// <summary> /// 绑定行的值 /// </summary> internal void DataBindRow() { GridColumnCollection columns = _grid.AllColumns; //int columnsCount = columns.Count; //// 如果Grid启用RowExpander,需要附加额外的数据 //if (!String.IsNullOrEmpty(Grid.RowExpander.DataFormatString)) //{ // columnsCount += Grid.RowExpander.DataFields.Length; //} // 计算每列的值 Values = new string[columns.Count]; //ExtraValues = new object[columns.Count]; States = new object[columns.Count]; int i = 0; for (int count = columns.Count; i < count; i++) { GridColumn column = columns[i]; Values[i] = StrimColumnValue(column.GetColumnValue(this)); if (column.PersistState) { States[i] = column.GetColumnState(this); } } //// 如果Grid启用RowExpander,需要附加额外的数据 //if (!String.IsNullOrEmpty(Grid.RowExpander.DataFormatString)) //{ // foreach (string field in Grid.RowExpander.DataFields) // { // Values[i++] = GetPropertyValue(field).ToString(); // } //} // 计算DataKeys的值 if (_grid.DataKeyNames != null) { string[] keyNames = _grid.DataKeyNames; DataKeys = new object[keyNames.Length]; for (int j = 0, count = keyNames.Length; j < count; j++) { DataKeys[j] = GetPropertyValue(keyNames[j]); } } }
public void InitTemplateContainers() { GridColumnCollection columns = _grid.AllColumns; TemplateContainers = new GridRowControl[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; GridRowControl control = new GridRowControl(DataItem, RowIndex); //control.ID = String.Format("{0}_{1}_{2}", Grid.ID, RowIndex, column.ColumnIndex); control.ID = String.Format("c{0}r{1}", column.ColumnIndex, RowIndex); field.ItemTemplate.InstantiateIn(control); Controls.Add(control); TemplateContainers[column.ColumnIndex] = control; } } }