/// <summary> /// Binds the extender columns. /// </summary> private void BindExtenderColumns() { List<GridViewColumnInfo> ciCollection = new List<GridViewColumnInfo>(); // fill GridViewColumnInfo collection AdminView view = MainListView.GetAdminView(); if (view != null) { // get settings string gridSettingsKey = CMPageSettings.MakeGridSettingsKey(this.AppId, this.ViewId); string oldGridSettings = ProfileContext.Current.Profile.PageSettings.GetSettingString(gridSettingsKey); EcfListViewPreferences prefs = null; if (!String.IsNullOrEmpty(oldGridSettings)) prefs = UtilHelper.JsonDeserialize<EcfListViewPreferences>(oldGridSettings); // set columns' properties gvHeaderExtender.ColumnsInfo.Clear(); foreach (ViewColumn viewColumn in view.Columns) { if (!viewColumn.Visible) continue; GridViewColumnInfo gvColumn = new GridViewColumnInfo(); gvColumn.Sortable = viewColumn.ColumnType == ColumnType.Action ? false : viewColumn.AllowSorting; gvColumn.Resizable = viewColumn.ColumnType == ColumnType.CheckBox || viewColumn.ColumnType == ColumnType.Action ? false : viewColumn.Resizable; int width = 0; if (viewColumn.ColumnType == ColumnType.CheckBox) // checkbox column should be of fixed width width = EcfListView.DefaultCheckboxColumnWidth; else { // set width if (prefs != null && prefs.ColumnProperties[viewColumn.ColumnIndex.ToString()] != null) width = Int32.Parse((string)prefs.ColumnProperties[viewColumn.ColumnIndex.ToString()]); else if (!Int32.TryParse(viewColumn.Width, out width)) width = EcfListView.DefaultColumnWidth; } gvColumn.Width = width; gvHeaderExtender.ColumnsInfo.Add(gvColumn); } } this.gvHeaderExtender.HeaderHeight = EcfListView.DefaultHeaderHeight; this.gvHeaderExtender.StyleInfo = new Mediachase.Ibn.Web.UI.WebControls.GridStylesInfo(MainListView.HeaderCssClass, MainListView.GridCssClass, MainListView.FooterCssClass, MainListView.HeaderInnerCssClass, MainListView.GridInnerCssClass, MainListView.GridSelectedRowCssClass); }
public void ColumnResize(string ContextKey, int ColumnIndex, int NewSize) { EcfListViewContextKey key = UtilHelper.JsonDeserialize <EcfListViewContextKey>(ContextKey); try { // get old settings string gridSettingsKey = CMPageSettings.MakeGridSettingsKey(key.AppId, key.ViewId); string oldGridSettings = ProfileContext.Current.Profile.PageSettings.GetSettingString(gridSettingsKey); EcfListViewPreferences prefs = null; if (!String.IsNullOrEmpty(oldGridSettings)) { prefs = UtilHelper.JsonDeserialize <EcfListViewPreferences>(oldGridSettings); } if (prefs == null) { prefs = new EcfListViewPreferences(key.AppId, key.ViewId); } int index = ColumnIndex; AdminView view = ManagementContext.Current.FindView(key.AppId, key.ViewId); if (view != null && view.Columns.Count > ColumnIndex) { // get real index of a column with visibleIndex==ColumnIndex // start search from column with index == ColumnIndex because its visibleIndex<=ColumnIndex for (int i = ColumnIndex; i < view.Columns.Count; i++) { if (view.Columns[i].ColumnVisibleIndex == ColumnIndex) { index = i; break; } } } prefs.ColumnProperties[index.ToString()] = NewSize.ToString(); // save new settings ProfileContext.Current.Profile.PageSettings.SetSettingString(gridSettingsKey, UtilHelper.JsonSerialize(prefs)); ProfileContext.Current.Profile.Save(); } catch (Exception ex) { // TODO: handle exception } }
private void BindExtenderColumns() { List <GridViewColumnInfo> list = new List <GridViewColumnInfo>(); AdminView adminView = this.MainListView.GetAdminView(); if (adminView != null) { CMPageSettings.MakeGridSettingsKey(this.AppId, this.ViewId); string input = string.Empty; EcfListViewPreferences listViewPreferences = (EcfListViewPreferences)null; if (!string.IsNullOrEmpty(input)) { listViewPreferences = UtilHelper.JsonDeserialize <EcfListViewPreferences>(input); } this.gvHeaderExtender.ColumnsInfo.Clear(); foreach (ViewColumn viewColumn in (CollectionBase)adminView.Columns) { if (viewColumn.Visible) { GridViewColumnInfo gridViewColumnInfo = new GridViewColumnInfo(); gridViewColumnInfo.Sortable = viewColumn.ColumnType != ColumnType.Action && viewColumn.AllowSorting; gridViewColumnInfo.Resizable = viewColumn.ColumnType != ColumnType.CheckBox && viewColumn.ColumnType != ColumnType.Action && viewColumn.Resizable; int result = 0; if (viewColumn.ColumnType == ColumnType.CheckBox) { result = 24; } else if (listViewPreferences != null && listViewPreferences.ColumnProperties[(object)viewColumn.ColumnIndex.ToString()] != null) { result = int.Parse((string)listViewPreferences.ColumnProperties[(object)viewColumn.ColumnIndex.ToString()]); } else if (!int.TryParse(viewColumn.Width, out result)) { result = 100; } gridViewColumnInfo.Width = result; this.gvHeaderExtender.ColumnsInfo.Add(gridViewColumnInfo); } } } this.gvHeaderExtender.HeaderHeight = 24; this.gvHeaderExtender.StyleInfo = new GridStylesInfo(this.MainListView.HeaderCssClass, this.MainListView.GridCssClass, this.MainListView.FooterCssClass, this.MainListView.HeaderInnerCssClass, this.MainListView.GridInnerCssClass, this.MainListView.GridSelectedRowCssClass); }