public void ColumnResize(string ContextKey, int ColumnIndex, int NewSize) { MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey); LoadMetaViewPreference(gridContextKey.ViewName); mvPref.SetMetaFieldWidth(ColumnIndex - gridContextKey.CustomColumnsCount, NewSize); SaveMetaViewPreferences(); }
/// {"primaryKeyId":6, "column":1, "value":"11:21"} public void UpdateGrid(string ContextKey, object[] ChangesArray) { //List<string> fieldName = new List<string>(); MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey); List <MetaObject> changed = new List <MetaObject>(); CHelper.AddToContext("GridUpdated", 1); LoadMetaViewPreference(gridContextKey.ViewName); MetaView CurrentView = GetViewByName(gridContextKey.ViewName); MetaObject[] list = CurrentView.List(mvPref); if (CurrentView.PrimaryGroupBy != null || CurrentView.SecondaryGroupBy == null) { if (CurrentView.SecondaryGroupBy != null) { list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list); } list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list); } foreach (Dictionary <string, object> obj in ChangesArray) { int primaryKeyId = Convert.ToInt32(obj["primaryKeyId"]); int columnId = Convert.ToInt32(obj["column"]); string value = Convert.ToString(obj["value"]); MetaObject tmp = GetMetaObjectById(list, primaryKeyId); MetaObject curObject = null; if (tmp != null) { curObject = MetaObjectActivator.CreateInstance(tmp.GetMetaType(), primaryKeyId); } else { continue; } curObject.Properties[GetFieldNameByIndex(columnId)].Value = GetMinutesFromString(value); changed.Add(curObject); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (MetaObject changeObj in changed) { changeObj.Save(); } tran.Commit(); } }
public void OrderChange(string ContextKey, int OldIndex, int NewIndex) { MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey); if (OldIndex - gridContextKey.CustomColumnsCount < 0) { return; } LoadMetaViewPreference(gridContextKey.ViewName); mvPref.ChangeMetaFieldOrder(OldIndex - gridContextKey.CustomColumnsCount, NewIndex - gridContextKey.CustomColumnsCount); SaveMetaViewPreferences(); }
public void LayoutResized(string ContextKey, string RegionName, int NewSize) { MetaGridContextKey gridContextKey = UtilHelper.JsonDeserialize <MetaGridContextKey>(ContextKey); LoadMetaViewPreference(gridContextKey.ViewName); string attrName = string.Empty; #region Convert west -> MarginLeft (etc.) switch (RegionName) { case "west": { attrName = "MarginLeft"; break; } case "east": { attrName = "MarginRight"; break; } case "north": { attrName = "MarginTop"; break; } case "south": { attrName = "MarginBottom"; break; } } #endregion mvPref.Attributes.Set(attrName, NewSize); SaveMetaViewPreferences(); }