protected override void LoadViewState(object savedState) { var myState = (object[])savedState; if (myState[0] != null) { base.LoadViewState(myState[0]); } if (myState[1] != null) { dtGlobal = (DataTable)myState[1]; MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); } }
protected void lnkfontlarger_Click(object sender, EventArgs e) { //griddiv.Style.Add("font-size", "16px"); //MainGridView.CssClass = "largerfontgrid"; MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } //MainGridView.CssClass = "largerfontgrid"; }
//This method is used for databinding the gridview to a dataSet from the BookWormService private void DataBindGridView() { //Declare the FilterAlgoithm class and use the filter method FilterAlgorithm filterSearch = new FilterAlgorithm(); //Remove ' to prevent sqlinjection/Exeption querystring = filterSearch.Filter(SearchTxtb.Text.Replace("'", ""), DdlGenre.Text, OrderByPreDdl.Text, OrderBySufDdl.Text); //Open a new instance of the bookWormService Service BookWormService = new Service(); //Execute the structed query MainGridView.DataSource = BookWormService.ExecuteQuery(querystring); //Databind MainGridView.DataBind(); //Dispose the resources BookWormService.Dispose(); }
private int GetColumnBestHeight(DevExpress.XtraGrid.Columns.GridColumn column) { try { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo viewInfo = MainGridView.GetViewInfo() as GridViewInfo; GridColumnInfoArgs ex = null; viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); ex.SetAppearance(MainGridView.Appearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, (int)(column.VisibleWidth - 10 * DpiXRel), 1000); } finally { viewInfo.GInfo.ReleaseGraphics(); } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); bool canDrawMore = true; Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; if (viewInfo.Painter != null) { res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; m_dictColumnHeight[column.Name] = res.Height; return(res.Height); } } catch (Exception ex) { MyLocalizer.XtraMessageBoxShow("В программе произошла ошибка. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(-1); }
public void SetUp(string[] columns, string tableName, DataTable data) { Data = data; GridColumns = columns; EntityName = tableName; MainGridView.DataSource = data; MainGridView.DataBind(); if (Session["CUDataObject"] == null) { Session.Add("CUDataObject", data); } else { Session["CUDataObject"] = data; } }
protected void drpAdvancedModeGrouping_SelectedIndexChanged(object sender, EventArgs e) { //if (drpGridViewMode.SelectedValue == "classic") //{ // this.ViewMode = GridViewMode.Classic; // dynAdvancedMode.Visible = true; //} //else //{ // txtInterval.Text = Convert.ToString(ApplicationCommon.GetAuditHistoryAdvancedModeInterval()); // dynAdvancedMode.Visible = true; // this.ViewMode = GridViewMode.Advanced; //} if (drpAdvancedModeGrouping.SelectedValue == "timeinterval") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.TimeInterval; if (string.IsNullOrEmpty(txtInterval.Text)) { txtInterval.Text = Convert.ToString(ConvertTimeIntervalInMinute(PerferenceUtility.GetUserPreferenceByKeyAsInt(ApplicationCommon.HistoryAdvancedModeIntervalKey))); } dynIntervalMode.Visible = true; } else { dynIntervalMode.Visible = false; if (drpAdvancedModeGrouping.SelectedValue == "auditaction") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.AuditAction; } else { AdvancedModeGrouping = GridViewAdvancedModeGrouping.ActionByAndAuditAction; } } var primaryKeyId = ViewState["PrimaryKey"].ToString(); dtGlobal = GetData(); Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
/// <summary> /// Export GridView content to XLS /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ExportToXslButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = "xls"; sfd.Filter = "Excel sheet (*.xls)|*.xls"; sfd.InitialDirectory = System.Environment.SpecialFolder.MyDocuments.ToString(); DialogResult result = sfd.ShowDialog(); if (sfd != null && result == DialogResult.OK && sfd.FileName != null && sfd.FileName != string.Empty) { MainGridView.ExportToXls(sfd.FileName); } } catch { ShowErrorMessage(Properties.Resources.ErrorDuringSavingXls); } }
private void bAcceptFind_Click(object sender, EventArgs e) { try { m_strFilterString = tFind.Text; FindEquipments(-1); MainGridView.ExpandAllGroups(); if (MainGridView.RowCount == 0) { NoFindEquipmentMessageForm f = new NoFindEquipmentMessageForm(); f.m_strMessage = "Конденсатор по поиску \"" + m_strFilterString + "\" отсутствует в базе данных. Добавить конденсатор?"; if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { long id = -1; PassportDataForm rf = new PassportDataForm(id, 0); rf.m_bShowContinueMsg = true; System.Windows.Forms.DialogResult dr = rf.ShowDialog(this); id = rf.m_id; if (dr == System.Windows.Forms.DialogResult.OK) { RefreshGridPos(id); } if (rf.m_bContinueNext) { ShowTestForm(id, rf.m_CondenserTestID); } } else { tFind.Focus(); } } } catch (Exception ex) { MyLocalizer.XtraMessageBoxShow("В программе произошла ошибка. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// DX doesn't support onRowDeleted event, so I have to reduce code redundancy by this way. /// </summary> /// <returns></returns> private async void DeleteSelectedPersonsFromDataGrid() { try { using (PersonsReference.PersonsServiceClient client = new PersonsReference.PersonsServiceClient()) { foreach (int rowNr in MainGridView.GetSelectedRows()) { PersonsReference.Person person = MainGridView.GetRow(rowNr) as PersonsReference.Person; ShowErrorMessage((await client.DeletePersonAsync(person)).Result); } } MainGridView.DeleteSelectedRows(); } catch { this.ShowErrorMessage(Properties.Resources.OtherErrorMessage); } }
private async void MainGridView_Loaded(object sender, RoutedEventArgs e) { if (_storeditem != null) { MainGridView.ScrollIntoView(_storeditem, ScrollIntoViewAlignment.Default); MainGridView.UpdateLayout(); ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("BackConnectedAnimation"); if (animation != null) { animation.IsScaleAnimationEnabled = true; animation.Configuration = new DirectConnectedAnimationConfiguration(); animation.Completed += (_sender, _e) => { MainGridView.ContainerFromItem(_storeditem).SetValue(OpacityProperty, 1.0d); }; await MainGridView.TryStartConnectedAnimationAsync(animation, _storeditem, "PlaceImage"); } } }
protected void Page_Load(object sender, EventArgs e) { //Check the cookies to see if the user is loggedin otherwise redirect to Register.aspx if (Request.Cookies["LoggedInCookie"] == null || (Request.Cookies["LoggedInCookie"] != null && Request.Cookies["LoggedInCookie"]["LoggedIn"] != "true")) { Response.Redirect("Register.aspx"); } //Check if the page has been loaded before if (!Page.IsPostBack) { //Add mouseenter/mouseover events to the image buttons FindYesBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/YesMouseOver.jpg'"); FindYesBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/YesDefault.jpg'"); FindNoBtn.Attributes.Add("onmouseover", "this.src = 'Resources/Images/NoMouseOver.jpg'"); FindNoBtn.Attributes.Add("onmouseout", "this.src = 'Resources/Images/NoDefault.jpg'"); //Databind items to the DropDownList (DdlGenere) using an ArrayCollection //Used to databind the dropdownlist with the book genres ArrayList DdlGenreArray = new ArrayList(); //DataBind the dropdownlist by getting the list from the ArrayCollections class ArrayCollections getlist = new ArrayCollections(); //Get the list DdlGenreArray = getlist.GenreList(); //Apply the source DdlGenre.DataSource = DdlGenreArray; //DataBind DdlGenre.DataBind(); //Open a new instance of the bookWormService Service BookWormService = new Service(); //Execute the query against the database on the service (Man, I love APIs) MainGridView.DataSource = BookWormService.ExecuteQuery("SELECT [BookId], [BookName], [BookImageUrl], [BookAuthor], [BookAverageRating] FROM [BookInformation] "); //Databind the gridView MainGridView.DataBind(); //Dispose of the Service Resources BookWormService.Dispose(); } }
private void SotrudnikView_Load(object sender, EventArgs e) { textBox1.Visible = is_error_handling; MainGridView.RowHeadersVisible = is_error_handling; mainview = new DataView(dataSet.Sotrudnik); selectedview = new DataView(dataSet.Sotrudnik); mainview.RowStateFilter = DataViewRowState.Added | DataViewRowState.ModifiedCurrent | DataViewRowState.Deleted; selectedview.RowStateFilter = DataViewRowState.ModifiedOriginal; //if (mainview.Count == 0) //{ // MessageBox.Show("Нет измененных данных"); // Close(); // return; //} MainGridView.DataSource = mainview; SelectedGridView.DataSource = selectedview; MainGridView.Columns["fam"].HeaderText = "Фамилия"; MainGridView.Columns["im"].HeaderText = "Имя"; MainGridView.Columns["otch"].HeaderText = "Отчество"; MainGridView.Columns["dr"].HeaderText = "День рождения"; MainGridView.Columns["pol"].HeaderText = "Пол"; MainGridView.Columns["cod_sotr"].Visible = false; panel1.Visible = false; this.MainGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.MainGridView_CellEnter); if (MainGridView.Rows.Count != 0) { MainGridView.CurrentCell = MainGridView.Rows[0].Cells["fam"]; } else { button1.Enabled = false; } MainGridView.Columns.Add("Статус", "Статус"); MainGridView.AutoResizeColumns(); MainGridView_DataBindingComplete(new object(), new DataGridViewBindingCompleteEventArgs(ListChangedType.Reset)); }
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { //In-built paging implementation MainGridView.PageIndex = e.NewPageIndex; MainGridView.DataBind(); CurrentPageIndex = e.NewPageIndex; //Synchronize with custom paging oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = e.NewPageIndex; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } }
private void toolTip_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) { if (e.SelectedControl == MainGridControl) { ToolTipControlInfo info = null; //Get the view at the current mouse position GridView view = MainGridControl.GetViewAt(e.ControlMousePosition) as GridView; if (view == null) { return; } //Get the view's element information that resides at the current position GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition); //Display a hint for row indicator cells if (hi.HitTest == GridHitTest.RowIndicator || hi.HitTest == GridHitTest.RowCell && hi.Column.FieldName == "CondenserState") { //An object that uniquely identifies a row indicator cell object o = hi.HitTest.ToString() + hi.RowHandle.ToString(); string text = ""; DataRow row = MainGridView.GetDataRow(hi.RowHandle); if (Convert.ToInt64(row["CondenserState"]) == 0) { text = "Работоспособен"; } else { text = "Неработоспособен"; } info = new ToolTipControlInfo(o, text); } //Supply tooltip information if applicable, otherwise preserve default tooltip (if any) if (info != null) { e.Info = info; } } }
protected void drpGridViewMode_SelectedIndexChanged(object sender, EventArgs e) { if (drpGridViewMode.SelectedValue == "classic") { ViewMode = GridViewMode.Classic; dynAdvancedMode.Visible = false; } else { txtInterval.Text = PerferenceUtility.GetUserPreferenceByKey(ApplicationCommon.HistoryAdvancedModeIntervalKey); dynAdvancedMode.Visible = true; ViewMode = GridViewMode.Advanced; } var primaryKeyId = ViewState["PrimaryKey"].ToString(); dtGlobal = GetData(); Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; MainGridView.DataBind(); }
private void MainGridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.FieldName == "CondenserState") { Rectangle rect = e.Bounds; int diametr = e.Bounds.Height - 4; rect.X = e.Bounds.X + e.Bounds.Width / 2 - diametr / 2; rect.Y = e.Bounds.Y + e.Bounds.Height / 2 - diametr / 2; rect.Width = rect.Height = diametr; DataRow row = MainGridView.GetDataRow(e.RowHandle); if (Convert.ToInt64(row["CondenserState"]) == 0) { e.Graphics.FillEllipse(new SolidBrush(Color.LightGreen), rect); } else { e.Graphics.FillEllipse(new SolidBrush(Color.Red), rect); } e.Graphics.DrawEllipse(new Pen(new SolidBrush(Color.Black)), rect); e.Handled = true; } }
private void RefreshGrid() { if (CurrentPageIndex != null) { MainGridView.PageIndex = CurrentPageIndex.Value; } else { MainGridView.PageIndex = 0; } MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = _getData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = MainGridView.PageIndex; oGridPagiation.ManagePaging(dtGlobal); if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); } }
private void RefreshGrid() { if (ViewState[Prefix + "CurrentPageIndex"] != null) { MainGridView.PageIndex = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } else { MainGridView.PageIndex = 0; } MainGridView.DataBind(); oGridPagiation = new GridPagiation(); dtGlobal = GetData(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.PageIndexInSession = MainGridView.PageIndex; oGridPagiation.ManagePaging(dtGlobal); if (ViewState[Prefix + "SortExpression"] != null && ViewState[Prefix + "SortDirection"] != null) { SortGridView(ViewState[Prefix + "SortExpression"].ToString(), ViewState[Prefix + "SortDirection"].ToString()); } }
private void RefreshGridPos(long id) { int f_row = MainGridView.FocusedRowHandle; if (id <= 0) { /*if (f_row > 0) f_row--; * FindEquipments(); * if (MainGridView.RowCount > f_row) * { * MainGridView.ClearSelection(); * MainGridView.SelectRow(f_row); * MainGridView.FocusedRowHandle = f_row; * }*/ return; } else { FindEquipments(id); for (int i = 0; i < MainGridView.RowCount /*this.dataSetQuery.QEquipments.Rows.Count*/; i++) { //DataRow r = this.dataSetQuery.QEquipments.Rows[i]; //int id_ = Convert.ToInt64(r["EquipmentID"]); long id_ = Convert.ToInt64(MainGridView.GetRowCellValue(i, "EquipmentID")); if (id_ == id) { MainGridView.ClearSelection(); MainGridView.SelectRow(i); MainGridView.FocusedRowHandle = i; return; } } } }
private void bAcceptFind_Click(object sender, EventArgs e) { m_strFilterString = tFind.Text; FindEquipments(-1); MainGridView.ExpandAllGroups(); if (MainGridView.RowCount == 0) { NoFindEquipmentMessageForm f = new NoFindEquipmentMessageForm(); f.m_strMessage = "Оборудование по поиску \"" + m_strFilterString + "\" отсутствует в базе данных. Добавить оборудование?"; if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { long id = -1; PassportDataForm rf = new PassportDataForm(id); rf.m_bShowContinueMsg = true; System.Windows.Forms.DialogResult dr = rf.ShowDialog(this); id = rf.m_id; if (dr == System.Windows.Forms.DialogResult.OK) { RefreshGridPos(id); } if (rf.m_bContinueNext) { ShowVisualForm(id, false); } } else { tFind.Focus(); } } }
/// <summary> /// Fills the Steps List with the Values of the DataGrid /// </summary> private void RetrieveValues() { MainGridView.UnselectAllCells(); steps = new List <Step>(); int rowcount = MainGridView.Items.Count; for (int z = 0; z < rowcount; z++) { TextBlock StepNumber = MainGridView.Columns[0].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepName = MainGridView.Columns[1].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepDescription = MainGridView.Columns[2].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepActions = MainGridView.Columns[3].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepsBefore = MainGridView.Columns[4].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepsAfter = MainGridView.Columns[5].GetCellContent(MainGridView.Items[z]) as TextBlock; TextBlock StepTime = MainGridView.Columns[6].GetCellContent(MainGridView.Items[z]) as TextBlock; if (StepName.Text != "") { steps.Add(new Step() { StepNumber = Convert.ToInt32(StepNumber.Text.Replace(" ", string.Empty)), Schritt = StepName.Text, Beschreibung = StepDescription.Text, Aktion = StepActions.Text, Vorheriger_Schritt = StepsBefore.Text, Nächster_Schritt = StepsAfter.Text, Zeit_Schritt = StepTime.Text }); } else { break; } } sheet = ComboSheet.SelectedItem.ToString(); }
private void SearchAutoBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { var items = MainGridView.ItemsSource as List <LittleAnimal>; if (Helpers.StringHelper.IsNullOrEmptyOrWhiteSpace(args.QueryText)) { var notify = new Helpers.NotifyPopup("请输入搜索内容"); notify.Show(); return; } var result = items.Find(p => p.Name == args.QueryText); if (result != null) { //MainGridView.ItemsSource = result; MainGridView.ScrollIntoView(result); MainGridView.SelectedItem = result; } else { var notify = new Helpers.NotifyPopup("没有找到"); notify.Show(); } }
public void ScrollMe(object sender, object parameter) { int selectedIndex = (int)((parameter as DependencyPropertyChangedEventArgs).NewValue); MainGridView.ScrollIntoView(MainGridView.Items[selectedIndex]); }
private DataTable SortGridView(string sortExpression, string sortDirection) { var tableFolder = ViewState["TableFolder"].ToString(); var tableName = ViewState["TableName"].ToString(); var primaryKeyId = ViewState["PrimaryKey"].ToString(); //var isTesting = (bool)(ViewState["IsTesting"]); var currentpage = MainGridView.PageIndex; var currentpagesize = MainGridView.PageSize; var totalnumofrows = MainGridView.Rows.Count; var dtlocal = new DataTable(); var sortedtable = new DataTable(); var dtlocal2 = new DataTable(); var floor = (currentpage * currentpagesize); var ceil = ((currentpage * currentpagesize) + currentpagesize) - 1; if (ceil > dtGlobal.Rows.Count) { ceil = dtGlobal.Rows.Count - 1; } if (ViewState["SessionUpdated"] != null) { dtGlobal = GetData(); } else { dtGlobal = GetDataSet(tableName); } //Extract Sort Info from Session if (ViewState[Prefix + "SortExpression"] != null) { if (dtGlobal.Columns.Contains(ViewState[Prefix + "SortExpression"].ToString())) { sortExpression = ViewState[Prefix + "SortExpression"].ToString(); } } if (ViewState[Prefix + "SortDirection"] != null) { sortDirection = ViewState[Prefix + "SortDirection"].ToString(); } else { if (sortDirection.Equals("Ascending")) { sortDirection = "ASC"; } else { sortDirection = "DESC"; } } var columns = new string[dtGlobal.Columns.Count]; var coltypes = new Type[dtGlobal.Columns.Count]; var cnt = 0; //create Data Table objects foreach (DataColumn column in dtGlobal.Columns) { columns[cnt] = column.ColumnName; coltypes[cnt] = column.GetType(); cnt++; } dtlocal.Clear(); dtlocal.Reset(); for (var i = 0; i < columns.Length; i++) { var dc = new DataColumn(columns[i], typeof(string)); sortedtable.Columns.Add(dc); var dc2 = new DataColumn(columns[i], typeof(string)); dtlocal.Columns.Add(dc2); var dc3 = new DataColumn(columns[i], typeof(string)); dtlocal2.Columns.Add(dc3); } //Load dtlocal with current rows in view for (var i = floor; i <= ceil; i++) { if (dtGlobal.Rows.Count >= ceil && i < dtGlobal.Rows.Count) { dtlocal.ImportRow(dtGlobal.Rows[i]); } } //sort current rows in view if (!string.IsNullOrEmpty(sortExpression)) { dtlocal2 = SortDataTable(dtlocal, sortExpression, sortDirection); } //rebuild the datatable with sorted rows in view and rest of the rows for (var i = 0; i < dtGlobal.Rows.Count; i++) { if (i == floor) { for (var j = 0; j <= dtlocal2.Rows.Count - 1; j++) { if (dtlocal2.Rows[j] != null) { sortedtable.ImportRow(dtlocal2.Rows[j]); } else { sortedtable.ImportRow(dtGlobal.Rows[j]); } } i = ceil + 1; } if (i < dtGlobal.Rows.Count) { sortedtable.ImportRow(dtGlobal.Rows[i]); } } // fix this name .. Sample(dtGlobal, primaryKeyId, HideData, SessionVariables.IsTesting); var dv = dtGlobal.DefaultView; // if blank, only should really be the first time // then we don't want to appened the sort instruction if (!string.IsNullOrEmpty(sortExpression) && dtGlobal.Columns.Contains(sortExpression)) { dv.Sort = sortExpression + " " + sortDirection; //System.Diagnostics.Debug.WriteLine(dv.Sort); } //Bind data based on the sort selection if (!skipgridreload) { //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort")) //{ MainGridView.DataSource = dv; MainGridView.DataBind(); //} //else //{ // MainGridView.DataSource = sortedtable; // MainGridView.DataBind(); //} if (MainGridView.AllowPaging) { if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.RefreshGrid = false; oGridPagiation.ManagePaging(dtGlobal); } } //if (RadioButtonList1.SelectedItem.Value.Equals("FTSort")) //{ return(dv.ToTable(ViewState["TableName"].ToString())); //} //else //{ // return sortedtable; //} }
public void Setup(int systemEntityId, int entityKey, string UserPreferenceCategory = "") { var tableName = "AuditHistory"; var primaryKey = "AuditHistoryId"; var isPaging = true; SystemEntityTypeId = systemEntityId; EntityKey = entityKey; Prefix = entityKey.ToString(); var userPreferenceCategory = UserPreferenceCategory; if (string.IsNullOrEmpty(userPreferenceCategory)) { userPreferenceCategory = tableName; } SetViewState(); var userGrouping = PerferenceUtility.GetUserPreferenceByKey(ApplicationCommon.HistoryAdvancedModeGroupingKey, userPreferenceCategory); if (userGrouping == "timeinterval") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.TimeInterval; txtInterval.Text = Convert.ToString(ConvertTimeIntervalInMinute(PerferenceUtility.GetUserPreferenceByKeyAsInt(ApplicationCommon.HistoryAdvancedModeIntervalKey))); drpAdvancedModeGrouping.SelectedValue = "timeinterval"; dynIntervalMode.Visible = true; } else { dynIntervalMode.Visible = false; if (userGrouping == "auditaction") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.AuditAction; drpAdvancedModeGrouping.SelectedValue = "auditaction"; } else if (userGrouping == "actionby") { AdvancedModeGrouping = GridViewAdvancedModeGrouping.ActionByAndAuditAction; drpAdvancedModeGrouping.SelectedValue = "actionby"; } } dtGlobal = GetData(); Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; if (isPaging) { MainGridView.PageSize = SessionVariables.DefaultRowCount; oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.ManagePaging(dtGlobal); } else { MainGridView.AllowPaging = isPaging; } MainGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { MainGridView.DataSource = SelectedData; MainGridView.DataBind(); }
public void Setup( string tableName, string tableFolder, string primaryKey, bool pageLoad , GetDataDelegate getDataDelegate, GetColumnDelegate getColumnDelegate , bool isPaging, int entityKey, string UserPreferenceCategory = "") { EntityKey = entityKey; Prefix = entityKey.ToString(); _getData = getDataDelegate; _getColumnDelegate = getColumnDelegate; ViewState["TableFolder"] = tableFolder; ViewState["TableName"] = tableName; var userPreferenceCategory = UserPreferenceCategory; if (string.IsNullOrEmpty(userPreferenceCategory)) { userPreferenceCategory = tableName; } if (ViewState[Prefix + "TableName"] == null) { ViewState.Add(Prefix + "TableName", tableName); } if (ViewState[Prefix + "TableName"] != null && !(ViewState[Prefix + "TableName"].ToString().Equals(tableName))) { ViewState[Prefix + "TableName"] = tableName; ViewState[Prefix + "CurrentPageIndex"] = 0; } ViewState["TableName"] = tableName; ViewState["PrimaryKey"] = primaryKey; //ViewState["IsTesting"] = SessionVariables.IsTesting; ViewState["PageLoad"] = pageLoad; dtGlobal = GetData(); Sample(dtGlobal, primaryKey, HideData, SessionVariables.IsTesting); MainGridView.DataSource = dtGlobal; if (isPaging) { MainGridView.PageSize = DefaultRowCount; oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dtGlobal, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; if (ViewState[Prefix + "CurrentPageIndex"] != null) { oGridPagiation.PageIndexInSession = int.Parse(ViewState[Prefix + "CurrentPageIndex"].ToString()); } oGridPagiation.ManagePaging(dtGlobal); } else { MainGridView.AllowPaging = isPaging; } MainGridView.DataBind(); }
//AJOUTER protected void Enregistrer(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { string idrole = Cl_Fonction.GetstringCmb("cmbrole", MainGridView); int idtypedoc = Cl_Fonction.GetIntCmb("cmbtypedoc", MainGridView); int statut = Cl_Fonction.GetIntCmb("cmbStatut", MainGridView); try { // on vérifie si les différents champs obligatoires ne sont pas vide if ((idrole.ToString() != "") && (idtypedoc.ToString() != "") && (statut.ToString() != "")) { ArrayList cle = new ArrayList(); ArrayList val = new ArrayList(); cle.Add("@ID_ROLE"); val.Add(idrole); cle.Add("@ID_TYPEDOC"); val.Add(idtypedoc); cle.Add("@STATUT"); val.Add(statut); cle.Add("@SENDER"); val.Add(1); cle.Add("@ID_AFFECT_ROLE"); val.Add(0); Cl_Fonction.Execute_Commande_StoreProc("PS_AFFECTATION_ROLE_TYPEDOC", cle, val); string code_message = message.CodeMessage.SUCCES.ToString(); string lib_message = Cl_Fonction.message_defini(code_message); MainGridView.JSProperties["cpShowPopup"] = code_message + "|" + lib_message; e.Cancel = true; MainGridView.CancelEdit(); chargerGrid(); } else { e.Cancel = true; string code_message = message.CodeMessage.ECHEC.ToString(); string lib_message = Cl_Fonction.message_defini(code_message); MainGridView.JSProperties["cpShowPopup"] = code_message + "|" + lib_message; } } catch (Exception ex) { e.Cancel = true; string code_message = message.CodeMessage.UNEXPECTED_ERROR.ToString(); string lib_message = Cl_Fonction.message_defini(code_message); MainGridView.JSProperties["cpShowPopup"] = code_message + "|" + lib_message; } }
private void ManageGridViewItemSelections() { foreach (var place in _places.SelectMany(p => p)) { place.PropertyChanged += (s, e) => { var gridViewItem = (GridViewItem)MainGridView.ContainerFromItem(place); var selectionToggle = gridViewItem.FindDescendant <ToggleButton>(); var centerX = (float)selectionToggle.ActualWidth / 2; var centerY = (float)selectionToggle.ActualHeight / 2; if (place.IsSelected) { _placesToCompare.Add(place); selectionToggle .Offset(offsetX: -92.0f, offsetY: -50.0f) .Scale(scaleX: 1.5f, scaleY: 1.5f, centerX: centerX, centerY: centerY) .Start(); } else { _placesToCompare.Remove(place); selectionToggle .Offset(offsetX: 0.0f, offsetY: 0.0f) .Scale(scaleX: 1.0f, scaleY: 1.0f, centerX: centerX, centerY: centerY) .Start(); } if (_placesToCompare.Count >= 2) { foreach (var item in MainGridView.Items) { if (item is Place p && !p.IsSelected) { if (MainGridView.ContainerFromItem(item) is GridViewItem element) { element.IsEnabled = false; } } } CommandBar.Visibility = Visibility.Visible; } else { foreach (var item in MainGridView.Items) { if (MainGridView.ContainerFromItem(item) is GridViewItem element) { element.IsEnabled = true; } } CommandBar.Visibility = Visibility.Collapsed; } MainGridView.IsItemClickEnabled = _placesToCompare.Count == 0; Wonderbar.Visibility = _placesToCompare.Count == 0 ? Visibility.Visible : Visibility.Collapsed; }; } }
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e) { int currentpage = MainGridView.PageIndex; int currentpagesize = MainGridView.PageSize; int totalnumofrows = MainGridView.Rows.Count; var floor = (currentpage * currentpagesize); var ceil = ((currentpage * currentpagesize) + currentpagesize) - 1; StringCollection sc = new StringCollection(); string id = String.Empty; DataTable dt1 = new DataTable(); CheckBox selectall = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll"); bool chkchecked = selectall.Checked; if (!string.IsNullOrEmpty(SessionVariables.SortExpression) && !string.IsNullOrEmpty(SessionVariables.SortDirection)) { skipgridreload = true; dt1 = SortGridView(SessionVariables.SortExpression, SessionVariables.SortDirection); skipgridreload = false; } else { dt1 = dtGlobal; } MainGridView.DataSource = dt1; MainGridView.DataBind(); oGridPagiation = new GridPagiation(); oGridPagiation.Setup(plcPaging, litPagingSummary, lblCacheStatus, dt1, MainGridView, Page, SettingCategory); oGridPagiation.Changed += oGridPagiation_Changed; oGridPagiation.ManagePaging(dt1); selectall = (CheckBox)MainGridView.HeaderRow.Cells[0].FindControl("chkSelectAll"); selectall.Checked = chkchecked; //loop the GridView Rows int j = 0; for (var i = floor; i <= ceil; i++) { if (j < MainGridView.Rows.Count) { CheckBox cb = (CheckBox)MainGridView.Rows[j].Cells[0].FindControl("CheckBox1"); //find the CheckBox if (cb != null && selectall != null) { if (selectall.Checked) { if (!cb.Checked) { cb.Checked = true; // add the id to be deleted in the StringCollection } } else { if (cb.Checked) { cb.Checked = false; } } } j++; } } }