Hi,
I have a page with a WebNumericEdit control and a grid....
a column with diferent values (1 ... 0,25 ... 0,345678952315 ... 1,05498 ... 400 ...)
I want that when the user enters the page,
the values presented to him be with, let's say, max of 3 decimal digits (in the example above 1 ... 0,25 ... 0,345 ... 1,054 ... 400) and when he enters edit mode, the hole cell value be showed to him...That's the normal behaviour off the grid by using it's column format property..
But I also need that the user see the cell value with a certain cultureInfo....I do that by using a NumericEditControl and then the column shows the hole value all the time.
Any Ideas???
Obs.: I have the following code in UltraWebGrid initialize Layout for the user to see the number formated in his CultureInfo when in editMode:
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("pt-BR"); ci.NumberFormat.NumberDecimalSeparator = ",";
//Set this property because if not, only 2 digits are showned
ci.NumberFormat.NumberDecimalDigits = 20; WebNumericEdit1.NumberFormat = ci.NumberFormat;
UltraWebGrid1.DisplayLayout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes; UltraWebGrid1.Columns[1].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom; UltraWebGrid1.Columns[1].EditorControlID = WebNumericEdit1.UniqueID;
Still no solution or workaround for this?
As Tony mentioned that if embedded editor provider is used, then editing and rendering is defined not by grid, but by editor. So, the only way around is to modify that editor (better to say: hack into its logic). All aspects of "embedded" features are defined byInfragistics.WebUI.Shared.IProvidesEmbeddableEditor. There are few methods on server and few methods on client. You will be interested in the getRenderedValue and RenderValue members.
To adjust value provided by editor after user edited cell, you need to override the getRenderedValue member function. Example below will limit number of digits after dot to 1.
<script type="text/javascript">function WebNumericEdit1_Initialize(oEdit, text){ oEdit.myOldGetRenderedValue = oEdit.getRenderedValue; oEdit.getRenderedValue = function(v) { var val = this.myOldGetRenderedValue(v); var dot = val.indexOf('.'); if(dot > 0 && dot + 2 < val.length) val = val.substring(0, dot + 2); return val; }}</script>
To support rendering of initial values is more complex. You need to remove WebNumericEdit from aspx, extend it and override its RenderValue. Below is example:
public partial class MyPage : System.Web.UI.Page{ // all your codes here
private MyWebNumericEdit WebNumericEdit1; protected override void OnInit(EventArgs e) //or //protected void Page_Load(object sender, EventArgs e) { this.WebNumericEdit1 = new MyWebNumericEdit(); this.WebNumericEdit1.ID = "WebNumericEdit1"; this.WebNumericEdit1.ClientSideEvents.Initialize = "WebNumericEdit1_Initialize"; this.Form.Controls.Add(this.WebNumericEdit1); }}
internal class MyWebNumericEdit : Infragistics.WebUI.WebDataInput.WebNumericEdit{ public override string RenderValue(object value) { string val = base.RenderValue(value); int dot = val.IndexOf('.'); if(dot > 0 && dot + 2 < val.Length) val = val.Substring(0, dot + 2); return val; }}