Hi all,
We use Infragistics 10.3 and cannot move to other version.
We have an UltraGrid and a column with images. I need to filter records by this column. Picture 1 shows what I have.
If I expand ValueList for this column, I see useless lines "System.Drawing.Bitmap" (see picture 2)
1. I want to see "good names" for all images.
To resolve this issue, I've added special class BitmapFilterCondition : FilterCondition, IConvertible with overridden method MeetsCriteria and changed filling of ValueList within BeforeRowFilterDropDownPopulate event. The result is at the picture 3.
But the next problems are:
2. the selected picture is doubled in the FilterRow. I expect to see "=" sign at the left side of filtered cell (see picture 4).
3. Also when I go out of filter and select any other cell, the value in FilterCell shows "System.Drawing.Bitmap" text instead of correct text (see picture 5).
4. Also when I click "Clear All Filters" button, the exception appears (see picture 6).
The source code of my example project is attached.
Can anybody help me to resolve all these issues or even better provide me example of really working code?
Thanks.
PS. Forum doesn't work properly (doesn't allow me to attach the source code).
There is the source:
private Bitmap create_ = new Bitmap(Resources.CreateView16); private Bitmap delete_ = new Bitmap(Resources.DeleteView16);
private void InitializeComponent() { this.components = new System.ComponentModel.Container(); Infragistics.Win.UltraWinGrid.UltraGridBand ultraGridBand1 = new Infragistics.Win.UltraWinGrid.UltraGridBand("Band 0", -1); Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn3 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Column 0"); Infragistics.Win.UltraWinGrid.UltraGridColumn ultraGridColumn4 = new Infragistics.Win.UltraWinGrid.UltraGridColumn("Column 1"); Infragistics.Win.UltraWinDataSource.UltraDataColumn ultraDataColumn1 = new Infragistics.Win.UltraWinDataSource.UltraDataColumn("Column 0"); Infragistics.Win.UltraWinDataSource.UltraDataColumn ultraDataColumn2 = new Infragistics.Win.UltraWinDataSource.UltraDataColumn("Column 1"); this.ultraGrid1 = new Infragistics.Win.UltraWinGrid.UltraGrid(); this.ultraDataSource1 = new Infragistics.Win.UltraWinDataSource.UltraDataSource(this.components); this.panel1 = new System.Windows.Forms.Panel(); ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ultraDataSource1)).BeginInit(); this.SuspendLayout(); // // ultraGrid1 // this.ultraGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.ultraGrid1.Cursor = System.Windows.Forms.Cursors.Default; this.ultraGrid1.DataSource = this.ultraDataSource1; ultraGridColumn3.Header.VisiblePosition = 0; ultraGridColumn4.Header.VisiblePosition = 1; ultraGridBand1.Columns.AddRange(new object[] { ultraGridColumn3, ultraGridColumn4}); this.ultraGrid1.DisplayLayout.BandsSerializer.Add(ultraGridBand1); this.ultraGrid1.DisplayLayout.Override.FilterClearButtonLocation = Infragistics.Win.UltraWinGrid.FilterClearButtonLocation.Row; this.ultraGrid1.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.FilterRow; this.ultraGrid1.Location = new System.Drawing.Point(8, 8); this.ultraGrid1.Name = "ultraGrid1"; this.ultraGrid1.Size = new System.Drawing.Size(447, 240); this.ultraGrid1.TabIndex = 1; this.ultraGrid1.Text = "UltraGrid1"; // // ultraDataSource1 // ultraDataColumn1.DataType = typeof(object); this.ultraDataSource1.Band.Columns.AddRange(new object[] { ultraDataColumn1, ultraDataColumn2}); // // panel1 // this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.panel1.Location = new System.Drawing.Point(8, 256); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(447, 32); this.panel1.TabIndex = 2; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(463, 294); this.Controls.Add(this.panel1); this.Controls.Add(this.ultraGrid1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1Load); ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ultraDataSource1)).EndInit(); this.ResumeLayout(false); } private void Form1Load(object sender, EventArgs e) { var row = ultraDataSource1.Rows.Add(); row[0] = create_; row[1] = "First"; row = ultraDataSource1.Rows.Add(); row[0] = delete_; row[1] = "Second"; row = ultraDataSource1.Rows.Add(); row[0] = delete_; row[1] = "Third"; ultraGrid1.DisplayLayout.Override.RowFilterMode = RowFilterMode.AllRowsInBand; SetImageColumnAppearence(ultraGrid1, 0); } public void SetImageColumnAppearence(UltraGrid grid, int index) { var editedColumn = grid.DisplayLayout.Bands[0].Columns[index]; editedColumn.FilterOperandStyle = FilterOperandStyle.DropDownList; editedColumn.FilterOperatorAppearance.ImageHAlign = HAlign.Left; editedColumn.CellAppearance.ImageHAlign = HAlign.Center; editedColumn.FilterOperatorDefaultValue = FilterOperatorDefaultValue.Equals; grid.BeforeRowFilterDropDownPopulate += delegate(object sender, BeforeRowFilterDropDownPopulateEventArgs e) { if (e.Column.Index != index) return; var bmps = GetAllRowsFilterItems(grid, e).Distinct().ToList(); foreach (var bitmap in bmps) { var item = e.ValueList.ValueListItems.Add( new BitmapFilterCondition(bitmap, GetCaption(bitmap))); item.Appearance.Image = bitmap; } e.Handled = true; }; grid.FilterCellValueChanged += delegate(object sender, FilterCellValueChangedEventArgs e) { if (e.FilterCell.Column.Index != index) return; var editor = e.FilterCell.EditorResolved; var bitmap = editor.IsValid ? editor.Value as BitmapFilterCondition : null; e.FilterCell.Appearance.ImageHAlign = HAlign.Left; e.FilterCell.Appearance.Image = bitmap != null ? bitmap.ToType(typeof (Bitmap), null) : null; e.FilterCell.Appearance.TextHAlign = HAlign.Left; //e.FilterCell.Value = bitmap; }; } private string GetCaption(Bitmap bitmap) { if (bitmap == create_) return "Create"; if (bitmap == delete_) return "Delete"; return string.Empty; } private static IEnumerable<Bitmap> GetAllRowsFilterItems(UltraGridBase grid, BeforeRowFilterDropDownPopulateEventArgs e) { var bitmaps = new List<Bitmap>(); var rows = (e.Rows as IEnumerable<UltraGridRow>) ?? grid.Rows.GetAllNonGroupByRows(); foreach (var row in rows) { if (row.Hidden) continue; var bitmap = row.Cells[e.Column].Value as Bitmap; if (bitmap == null) continue; bitmaps.Add(bitmap); } return bitmaps; } } internal class BitmapFilterCondition : FilterCondition, IConvertible { #region Private Fields private readonly Image bitmap_; private readonly string caption_; #endregion // Private Fields #region Constructors/Destructors public BitmapFilterCondition(Image bitmap, string caption) : base(FilterComparisionOperator.Equals, bitmap) { bitmap_ = bitmap; caption_ = caption; //ComparisionOperator = FilterComparisionOperator.Equals; //CompareValue = bitmap_; } #endregion // Constructors/Destructors #region Public Methods public override bool MeetsCriteria(UltraGridRow row) { return bitmap_ == row.Cells[Column.Key].Value as Bitmap; } public override string ToString() { return caption_; } #endregion // Public Methods #region IConvertible Members public TypeCode GetTypeCode() { return TypeCode.Object; } public bool ToBoolean(IFormatProvider provider) { throw new NotImplementedException(); } public char ToChar(IFormatProvider provider) { throw new NotImplementedException(); } public sbyte ToSByte(IFormatProvider provider) { throw new NotImplementedException(); } public byte ToByte(IFormatProvider provider) { throw new NotImplementedException(); } public short ToInt16(IFormatProvider provider) { throw new NotImplementedException(); } public ushort ToUInt16(IFormatProvider provider) { throw new NotImplementedException(); } public int ToInt32(IFormatProvider provider) { throw new NotImplementedException(); } public uint ToUInt32(IFormatProvider provider) { throw new NotImplementedException(); } public long ToInt64(IFormatProvider provider) { throw new NotImplementedException(); } public ulong ToUInt64(IFormatProvider provider) { throw new NotImplementedException(); } public float ToSingle(IFormatProvider provider) { throw new NotImplementedException(); } public double ToDouble(IFormatProvider provider) { throw new NotImplementedException(); } public decimal ToDecimal(IFormatProvider provider) { throw new NotImplementedException(); } public DateTime ToDateTime(IFormatProvider provider) { throw new NotImplementedException(); } public string ToString(IFormatProvider provider) { return caption_; } public object ToType(Type conversionType, IFormatProvider provider) { if (conversionType.IsAssignableFrom(bitmap_.GetType())) return bitmap_; return null; } #endregion }
Hello Dimam,
Could you please tell us what is your current version. I try to reproduce your scenario using the latest available service release for version 10.3.20103.2115 and everything works properly If you are using older version, you could download the latest service release from our site: Infragistics.com -> MyIG -> My keys and Downloads. Please take a look at the attached sample and video file. If you have any questions, do not hesitate to write me
Regards
Hello Georgi,
I will try to explain my requirements more clear.
I want to get the following picture:
Please, pay attention to:
1. Names in value list are "well-formed" (Create/Delete). In your case they are ("System.Drawing.Image")
2. Name in filter cell is also "well-formed". In your case it is "System.Drawing.Image".
3. At the left of the text in filter cell there is the image. It is the most important requirement!
4. At the left of the image in filter cell there is FilterOperator "=". It is also very important for us! Instead of "equals" there should be ability to set "not equals".
5. Dropped-down value list should contains only our images and "All" item.
6. Also it should not be ability to type or change text in filter cell with image. It can be set only with values from dropped-down value list.(In your case, the text in the cell can be changed manually to any other unknown value).
Can you suggest me something, please?
My requirements were described as clear as possible. We need this feature done or any advices how it can be implemented ASAP. Any news or ideas on that?
I still work at your task and I`ll try to provide you a sample.
Here is the mentioned sample. Could you please take a look at the attached file and let me know if you have any questions.
Now I load the images...
I have a grid with multiple columns of images.
I filtered like the example (UltraGridWithImageColumnFilter.zip) but when opened dropdown filter 2, the image in filter 1 is changed for a wrong Image.
I am going to explain more clearly:
We have two columns with images in each column.
Select 'Green' in column 'Image':
When opened Dropdown filter in ‘Egami’ column then green color is changed for Blue color in 'Image' column filter:
I select yellow color. The blue color still remains in 'Image' column filter:
When filter in 'Egami' column lost focus, then the green color appear in 'Image' filter:
Can you help me?
Thanks!
I use Infragictics 13.1.
Regards.
Hello!
Thanks for the feedback. If you have any questions, do not hesitate to write us
The main issue has gone!
Thanks a lot for your help.
Hi Dimam,
Could you please take a look at the modifications that I made in the sample. Pleas let me know if you have any questions.