private void popUpGrid_Opening(object sender, CancelEventArgs e) { DataTableFilterSortData data = _filterSortData; popUpFilterClear.Visible = (data != null && !String.IsNullOrEmpty(data.CurrentFilterExpression)); popUpSortClear.Visible = (data != null && !String.IsNullOrEmpty(data.CurrenSortExpression)); }
private void grd_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataTableFilterSortData data = _filterSortData; if (data == null) { return; } DataGridViewColumn col = grd.Columns[e.ColumnIndex]; DataView v = DataView; Cursor currentCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; ShowStatusProgress("Sorting data..."); if (Control.ModifierKeys == Keys.Shift) { if (data.SortCols.ContainsKey(col.DataPropertyName)) { data.SortCols.Remove(col.DataPropertyName); } } else if (Control.ModifierKeys != Keys.Control) { //data.SortCols.Clear(); //data.PrepareSortOrderFor(col.DataPropertyName); //data.SortCols[col.DataPropertyName] = grd.SortOrder; //data.CurrenSortExpression = data.GenerateSortExpression(); //return; SortOrder sortOrder = SortOrder.None; if (data.SortCols.ContainsKey(col.DataPropertyName) && data.SortCols.Count == 1) { sortOrder = data.SortCols[col.DataPropertyName]; } data.SortCols.Clear(); data.SortCols.Add(col.DataPropertyName, sortOrder); data.PrepareSortOrderFor(col.DataPropertyName); } else { data.PrepareSortOrderFor(col.DataPropertyName); } v.Sort = data.GenerateSortExpression(); data.CurrenSortExpression = v.Sort; } finally { Cursor.Current = currentCursor; HideStatusProgress(); RefreshResultSortStatus(); } }
public void RenderDataTable(DataTable dataTable) { _sourceDataTable = dataTable; ActiveDataTable = dataTable; CreateColumns(); _filterSortData = new DataTableFilterSortData(); InitializeFilterSortToolStripData(); }
private void InitializeFilterSortToolStripData() { ddlFilterType.Text = _filterSortData.FilterType; txtFilterDt.Text = _filterSortData.EditingFilterExpression; txtFilterDt.AutoCompleteCustomSource.Clear(); txtFilterDt.AutoCompleteCustomSource.AddRange(DataTableFilterSortData.ListToStringArray(_filterSortData.FilterExpressions)); RefreshResultFilterStatus(); }
private void RefreshResultSortStatus() { DataTableFilterSortData data = _filterSortData; string summary = (String.IsNullOrEmpty(data.CurrenSortExpression) || data.CurrenSortExpression.Length < 50) ? data.CurrenSortExpression : (data.CurrenSortExpression.Substring(0, 50) + "..."); statLblSortDt.Text = summary; statLblSortDt.ToolTipText = data.CurrenSortExpression; EvaluateResultStatusVisibility(); }
public void RenderDataTable(DataTable dataTable) { grd.DataSource = dataTable; foreach (DataGridViewColumn col in grd.Columns) { col.SortMode = DataGridViewColumnSortMode.Programmatic; } _filterSortData = new DataTableFilterSortData(); InitializeFilterSortToolStripData(); }
private void grd_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataTableFilterSortData data = _filterSortData; if (data == null || ActiveDataTable == null) { return; } if (String.IsNullOrEmpty(data.CurrenSortExpression)) { _prevUnsortedTable = ActiveDataTable; } DataGridViewColumn col = grd.Columns[e.ColumnIndex]; DataView v = NeedNewActiveDataView(); Cursor currentCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; ShowStatusProgress("Sorting data..."); if (Control.ModifierKeys == Keys.Shift) { if (data.SortCols.ContainsKey(col.DataPropertyName)) { data.SortCols.Remove(col.DataPropertyName); } } else if (Control.ModifierKeys != Keys.Control) { SortOrder sortOrder = SortOrder.None; if (data.SortCols.ContainsKey(col.DataPropertyName) && data.SortCols.Count == 1) { sortOrder = data.SortCols[col.DataPropertyName]; } data.SortCols.Clear(); data.SortCols.Add(col.DataPropertyName, sortOrder); data.PrepareSortOrderFor(col.DataPropertyName); } else { data.PrepareSortOrderFor(col.DataPropertyName); } v.Sort = data.GenerateSortExpression(); ActiveDataTable = v.ToTable(); grd.RowCount = ActiveDataTable.Rows.Count; data.CurrenSortExpression = v.Sort; } finally { Cursor.Current = currentCursor; HideStatusProgress(); RefreshResultSortStatus(); grd.Invalidate(); } }