Hi,
I wanted to know how can the content of the cell be masked on tab out of the cell?
Ex: SSN- 1234567890 masked content should be ******7890.
Also once the cell is masked how can the original value be read on a button click for some processing .
Regards
Suhas
Suhas,
What editor control are you using? We have editor controls on multiple platforms and the approach will be different depending on the platform.
Let me know if you have any questions with this matter.
You can use a mask on the column for when in edit mode to enter the social security number and then use a draw filter to mask the value when it is displayed while the cell isn't in edit mode.
The following is the code that would be used to set up the column for the grid as well as adding the draw filter:
this.ultraGrid1.DataSource = this.GetEmployees(10); this.ultraGrid1.DrawFilter = new SSNDrawFilter(); UltraGridColumn col = this.ultraGrid1.DisplayLayout.Bands[0].Columns["SSN"]; col.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals; col.MaskInput = "###-##-####"; col.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
The following is the implementation of the draw filter:
public class SSNDrawFilter : IUIElementDrawFilter { public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UltraGridCell cell = drawParams.Element.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell.Column.Key == "SSN") { TextUIElement textElement = (TextUIElement)drawParams.Element; textElement.Text = "*******"; if (cell.Text.Length > 7) { textElement.Text += cell.Text.Substring(7); } } return false; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is TextUIElement && drawParams.Element.Parent is MaskedEditUIElement) return DrawPhase.BeforeDrawElement; return DrawPhase.None; } }
I have also attached a sample that you can reference.