I have an UltraWebGrid (below) that is dynamically bound by Dataset server-side. I need it to have a row edit template with textbox, dropdownlist, and datepicker. I have several problems: 1) I cannot initialize the controls, like prefilling the dropdownlist, 2) I cannot set the initial values to the controls or get the changed values from them, 3) I have to do everything server-side in the code-behind, I cannot manipulate the data client-side, so no javascript. I've tried the various grid methods like updaterow, updategrid, etc., but cannot capture the right event(s). I am using vb.net 2008 with ig controls v10.3.20103.2134. I also cannot use the newer WebDataGrid, this has to be UltraWebGrid for now. I need to have something working correctly soon, so any help or simple example would be hugely appreciated. Thanks so much.
<igtbl:UltraWebGrid ID="igGrid" runat="server" DisplayLayout-AutoGenerateColumns="true"EnableAppStyling="True" StyleSetName="Office2007Blue" StyleSetPath="~/ig_res/"DisplayLayout-CellPaddingDefault="5" DisplayLayout-AllowSortingDefault="No"><Bands><igtbl:UltraGridBand><AddNewRow View="NotSet" Visible="NotSet"></AddNewRow></igtbl:UltraGridBand></Bands><DisplayLayout BorderCollapseDefault="Separate" CellPaddingDefault="5" Name="igStop" RowHeightDefault="20px" Version="4.00" CellClickActionDefault="Edit" AllowUpdateDefault="Yes"><FrameStyle></FrameStyle><ActivationObject BorderColor="" BorderWidth=""></ActivationObject></DisplayLayout></igtbl:UltraWebGrid>
Hello dbishop9,
Thank you for sharing your approach.
I’m glad that you managed to resolved your issue.
Let me know if you have any further need of assistance with this issue.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Hi Maya. I have resolved the issue on my own. While this may not be the "best" way to do it, it is the only one so far that has worked for me. In the BeforeRowTemplateOpenHandler, just before I assign the cell's date value to the WebDateChooser, I manually format the UTC date by using a bit of free javascript from the following link rather than spending time building my own formatting function.(I don't know if it's okay to include an outside link or not).
http://blog.stevenlevithan.com/archives/date-time-format
So now my code is:
function igMyGrid_BeforeRowTemplateOpenHandler(gridName, rowId, templateId) { var row = igtbl_getRowById(rowId); var currentValDueDate = row.getCell(1).getValue(); var currentValueCompletedDate = row.getCell(6).getValue(); currentValDueDate = dateFormat(currentValDueDate, "mm/dd/yyyy"); currentValueCompletedDate = dateFormat(currentValueCompletedDate, "mm/dd/yyyy"); dateChooserDueDate.value = currentValDueDate; dateChooserDueDate.inputBox.value = currentValDueDate; dateChooserCompletedDate.value = currentValueCompletedDate; dateChooserCompletedDate.inputBox.value = currentValueCompletedDate;}
function igMyGridDueDate_InitializeDateChooser(oDateChooser) { dateChooserDueDate = oDateChooser;}function igMyGridCompletedDate_InitializeDateChooser(oDateChooser) { dateChooserCompletedDate = oDateChooser;
}
This now makes the WebDateChooser display the initial date value as 02/01/2012, as I need it to to fulfill the requirements. Again, I'm still not sure what I have set or not set that was causing the previous methods to fail, but this overrides that and gives me the expected result I need.
Here is what I have in both HTML & code. How do I set the culture?
<igsch:WebDateChooser ID="igDueDate" runat="server" EnableAppStyling="True" Section508Compliant="true" StyleSetName="Office2007Blue" Format="Short" DisplayModeFormat="d" EditModeFormat="d" StyleSetPath="~/ig_res/" NullDateLabel="Select a Date"AllowNull="true" ClientSideEvents-InitializeDateChooser ="igDueDate_InitializeDateChooser"></igsch:WebDateChooser>
With e.Layout.Bands(0).Columns.FromKey("DATE").Header.Caption = "Due Date".DataType = "System.DateTime".Format = "MM/dd/yyyy".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.Center.Width = Unit.Pixel(75)End With
Hello dbishop9 ,
Have you tried setting the ShortDatePattern with:
c.DateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
Where c is the current culture info.
Also you need to set for the Format prorty of the WebDateChooser to Short. For example:
<igsch:WebDateChooser ID="WebDateChooser1" columnkey="Data" runat="server" AllowNull="false" Format="Short" OnInit="WebDateChooser1_Init">
<ClientSideEvents InitializeDateChooser="WebDateChooser1_InitializeDateChooser">
</ClientSideEvents>
</igsch:WebDateChooser>
Hi Maya, That was the problem. I didn't know I had to actually initialize the clent-side events. I haven't had to do that for other controls. Thanks so much. I still can't get the display/text format to work. I've set the display format to "d" and it works after I've selected a date, but for the initial date it shows the Fri Sept 30 00:00:00 CDT 2011 format. I've set it in the control, in the code-behind on row initalize and control initialize, but nothing seems to work. I've even captured the value from the grid cell, formatting it, then assigned it to the control, but it still fails. This will keep me from using the grid, because the date has to initially display as mm/dd/yyyy. Any ideas?