Dear Friends,
I m using a Webdatetimeedit in Ultrawebgrid column.
For this column i have set the datatype as System.Datetime and Format as dd/MM/yyyy.
My Ultrawebgrid has add row button(AddnewBox) which adds the new row to Ultrawebgrid
And for the Webdatetimeedit I have set the following properties
<igtxt:webdatetimeedit id="WebDateTimeEdit1" runat="server" Width="106px" EditModeFormat="dd/MM/yyyy " DisplayModeFormat="dd/MM/yyyy"></igtxt:webdatetimeedit>
On Pageload event I don't have any row in my ultrawebgrid.So user can add the row using add button.After adding row When i edit the Column and set the date as "01/01/2010" in the cell it ( it shows me the Proper value of cell as "01/01/2010") saves the Date but when
I edit the column and set the date as "25/01/2010" in the cell it gives me the error because at runtime it shows me the value of cell as nothing instead of "25/01/2010"
Hi,
I tested sample where grid has no rows, has addNewButton and editor with dd/MM/yyyy. It worked ok and picked up value of date, persisted it, could edit cell after a postback after after editing new row or cell in existing row.
If grid has custom editor, then there is no need to set Format of column.Maybe after a postback something happens to grid settings: column editor is lost or cell value is in wrong format. Try to experiment with simplest possible application (grid and editor on form and only initialization codes for grid and its editor) and test if it works correctly.
I had codes as below.
aspx:
<igtxt:WebDateTimeEdit ID="WebDateTimeEdit1" runat="server" EditModeFormat="dd/MM/yyyy"></igtxt:WebDateTimeEdit><igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" OnInitializeLayout="UltraWebGrid1_InitializeLayout" ... > <displaylayout ... AllowAddNewDefault="Yes"> ...
aspx.cs:
protected override void OnInit(EventArgs e){ base.OnInit(e); this.UltraWebGrid1.InitializeDataSource += new Infragistics.WebUI.UltraWebGrid.InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);}void UltraWebGrid1_InitializeDataSource(object sender, Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e){ DataTable dt = new DataTable("Customer"); dt.Columns.Add("CustomerID", typeof(int)); dt.Columns.Add("CustomerName", typeof(string)); dt.Columns.Add("Address", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); this.UltraWebGrid1.DataSource = dt;}protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e){ this.UltraWebGrid1.Columns[3].EditorControlID = this.WebDateTimeEdit1.UniqueID; this.UltraWebGrid1.Columns[3].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom;}
Hi Viktor ,
I tried your code I didn't understood your approach.If I remove the column setting format System.Datetime it does not allow to edit the date in dateformat it act as if im typing any
string in it.Why do I need InitializeDataSource event ,InitializeLayout event? I m not going to bind any data.My grid has 7 to 8 columns on postback it clears the date column(or cell) . but retains and shows the information of all 7 columns and rows added(via addnew button).
It clears the date when and only when the date is above 12 of specific month.
Like '13/12/2010','14/12/2010','16/1/2010' etc
It has been 20 days I m trying pls victor I need Help
Regards
Chandrakant
Hi Chandrakant,
There is no requirement to process InitializeLayout or DataSource events in order to configure custom cell editors. That can be done completely within aspx at visual design.In any case, in order for WebDateTimeEdit to work as embedded editor for grid, the Type of column should be DateTime. Otherwise, grid will not be able to interpret value obtained from editor on end edit mode and grid will not be able to initialize value in editor on start edit mode. It also will not be able to render value correctly: editor generates string in desired format. Otherwise the default javascript string for a Date would be displayed. If you want to know how that string would appear, you may test something likevar date = new Date();alert('Date string with default javascript conversion:' + date);
You probably would not like to have similar values in cells of your grid.In order to support embedded editor for grid, the WebDateTimeEdit implements IProvidesEmbeddableEditor interface and by its CanEditType method it returns true only for System.DateTime object. On client that editor on start edit mode expects the javascript Date object (but not String) and on end edit mode it returns Date to grid.
Below is example to configure WebDateTimeEdit as cell editor for a column in grid at visual design.
<bands> <igtbl:UltraGridBand> <Columns> <igtbl:UltraGridColumn DataType="System.DateTime" EditorControlID="WebDateTimeEdit1" Type="Custom"> </igtbl:UltraGridColumn> </Columns> </igtbl:UltraGridBand></bands>