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 posting in our forum.
If you don’t want to use any JS you’ll have to use the WebDateChooser control instead of the WebDatePicker since the latter is part of the Akido controls set and is better integrated with the new WebDataGrid .You can still use it but you’ll have to handle client side events to get and set the value of the corresponding cell you want to edit. For the WebDateChooser these client side events are already handled so you don’t need to write additional JS.
I’m attaching a sample for your reference. Please test it on your side and let me know if you have any concerns or questions.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Maya, below is what I have (it won't let me add an attachment). I have a couple of problems; 1) the edit template is aligned to the top of the row, not the bottom, which causes part of it to be off screen and it won't scroll up, 2) the dropdowns are not popluated. I followed your example, but I must not be doing something right. Please help. Also, how do I get the data from the controls in the edit template? Thanks
<igtbl:UltraWebGrid ID="igAction" runat="server" EnableAppStyling="True" StyleSetName="Office2007Blue" StyleSetPath="~/ig_res/" DisplayLayout-CellPaddingDefault="5" OnUpdateRow="igActions_UpdateRow"><Bands><igtbl:UltraGridBand><Columns><igtbl:UltraGridColumn BaseColumnName="ID" Key="ID"></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Process" Key="Process"><Header><RowLayoutColumnInfo OriginX="2" /></Header><Footer><RowLayoutColumnInfo OriginX="2" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Action Item" Key="Action Item"><Header><RowLayoutColumnInfo OriginX="3" /></Header><Footer><RowLayoutColumnInfo OriginX="3" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Action Type" Key="Action Type"><Header><RowLayoutColumnInfo OriginX="4" /></Header><Footer><RowLayoutColumnInfo OriginX="4" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Status" Key="Status"><Header><RowLayoutColumnInfo OriginX="5" /></Header><Footer><RowLayoutColumnInfo OriginX="5" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Assigned To" Key="Assigned To"><Header><RowLayoutColumnInfo OriginX="6" /></Header><Footer><RowLayoutColumnInfo OriginX="6" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Due Date" Key="Due Date" Format="MM/dd/yyyy"><Header><RowLayoutColumnInfo OriginX="7" /></Header><Footer><RowLayoutColumnInfo OriginX="7" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="Completion Date" Key="Completion Date" Format="MM/dd/yyyy"><Header><RowLayoutColumnInfo OriginX="8" /></Header><Footer><RowLayoutColumnInfo OriginX="8" /></Footer></igtbl:UltraGridColumn><igtbl:UltraGridColumn BaseColumnName="DATE" Key="DATE"><Header><RowLayoutColumnInfo OriginX="9" /></Header><Footer><RowLayoutColumnInfo OriginX="9" /></Footer></igtbl:UltraGridColumn></Columns><RowEditTemplate><p align="left"><asp:DropDownList ID="ddlActionProcess" runat="server" columnkey="Process" DataTextField="Process" OnInit="ddlActionProcess_Init"></asp:DropDownList><input id="txtActionItem" columnkey="Action Item" style="width:150px;" type="text" /><asp:DropDownList ID="ddlActionItem" runat="server" columnkey="Action Item" DataTextField="Action Item"OnInit="ddlActionItem_Init"></asp:DropDownList><asp:DropDownList ID="ddlActionStatus" runat="server" columnkey="Status" DataTextField="Status"OnInit="ddlActionStatus_Init"></asp:DropDownList><input id="txtActionAssignedTo" columnkey="Assigned To" style="width: 100px;" type="text" /><igsch:WebDateChooser ID="igActionDueDate" columnkey="Due Date" runat="server" NullDataLabel="Select a Date" Format="Short" OnInit="igActionDueDate_Init"></igsch:WebDateChooser><igsch:WebDateChooser ID="igActionCompletionDate" columnkey="Completion Date" runat="server" NullDataLabel="Select a Date"Format="Short" OnInit="igActionCompletionDate_Init"></igsch:WebDateChooser><igsch:WebDateChooser ID="igActionDate" columnkey="DATE" runat="server"NullDataLabel="Select a Date" Format="Short" OnInit="igActionDate_Init"></igsch:WebDateChooser><br /><br /></p><br /><p align="center" ><input id="igAction_reOkBtn" onclick="igAction_gRowEditButtonClick(event);" style="width: 50px;"type="button" value="OK"> <input id="igAction_reCancelBtn" onclick="igAction_gRowEditButtonClick(event);" style="width: 50px;"type="button" value="Cancel"> </input></input></p></RowEditTemplate><AddNewRow View="NotSet" Visible="NotSet"></AddNewRow></igtbl:UltraGridBand></Bands><DisplayLayout Name="igAction" AllowDeleteDefault="Yes" AllowSortingDefault="No" AllowUpdateDefault="RowTemplateOnly" BorderCollapseDefault="Separate" CellPaddingDefault="5" AutoGenerateColumns="false" RowSelectorsDefault="No" RowHeightDefault="20px" Version="4.00" CellClickActionDefault="Edit" SelectTypeRowDefault="Extended" StationaryMargins="Header" TableLayout="Fixed" ><FrameStyle></FrameStyle><ActivationObject BorderColor="" BorderWidth=""></ActivationObject></DisplayLayout></igtbl:UltraWebGrid>
********************************************************
Imports SystemImports System.DataImports System.Data.SqlClientImports System.Collections.GenericImports System.WebImports System.Web.UIImports System.Web.UI.WebControlsImports InfragisticsImports Infragistics.WebUIImports Infragistics.WebUI.UltraWebGridImports Infragistics.WebUI.WebSchedule
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadSetSubtitle()If Not IsPostBack ThenResponse.Cache.SetNoServerCaching()Response.Cache.SetCacheability(HttpCacheability.NoCache)ClearCache()LoadData()End If
End Sub Private Sub LoadData()Dim ds As New DataSetTryds = GetActionDataSet()igAction.DataSource = dsigAction.DataBind()Catch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionProcess_Init(ByVal sender As Object, ByVal e As EventArgs)TryDim d As DropDownList = DirectCast(sender, DropDownList)Dim ds As New DataSet
ds = GetDataSet("processes)If IsDatasetValid(ds) Thend.DataSource = dsd.DataBind()End IfCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionType_Init(ByVal sender As Object, ByVal e As EventArgs)Dim d As DropDownList = DirectCast(sender, DropDownList)Dim ds As New DataSet
TryTryds = GetDataSet("actiontypelist")If IsDatasetValid(ds) Thend.DataSource = dsd.DataBind()End IfCatch ex As ExceptionEnd TryCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionStatus_Init(ByVal sender As Object, ByVal e As EventArgs)Dim d As DropDownList = DirectCast(sender, DropDownList)Dim ds As New DataSet
TryTryds = GetDataSet("statuslist")If IsDatasetValid(ds) Thend.DataSource = dsd.DataBind()End IfCatch ex As ExceptionEnd TryCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionDueDate_Init(ByVal sender As Object, ByVal e As EventArgs)TryDim c As WebDateChooser = DirectCast(sender, WebDateChooser)c.Format = DateFormat.ShortCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionCompletionDate_Init(ByVal sender As Object, ByVal e As EventArgs)TryDim c As WebDateChooser = DirectCast(sender, WebDateChooser)c.Format = DateFormat.ShortCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igActionDate_Init(ByVal sender As Object, ByVal e As EventArgs)TryDim c As WebDateChooser = DirectCast(sender, WebDateChooser)c.Format = DateFormat.ShortCatch ex As ExceptionEnd TryEnd Sub
Protected Sub igAction_UpdateRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs)
End Sub
Sorry, it is setting it to the current date, not the date in the grid cell.
Hello dbishop9 ,
Does this happen when you run the sample i've attached as well?
On my side this code works as expected.The "Select a Date" would show probably if you've set the AllowNull to true. You need to set the :
dateChooser.Object.inputBox.value=currentVal;
This is the line that actually sets the value.
Would you like me to translate the same sample in VB?
Yes, if there is no date, it now sets it to Select a Date, however, when there is a date, it is also setting it to Select a Date, not the date in the grid cell from the record.
I'm just following up to see if you need any further assistance with this issue.
If so please let me know.
Sorry, Maya. I thought I had this but I don't. I have copied/used exactly what you have sent, but it doesn't set the dates according to what is in the grid. It sets both my controls to the dates of the first row of the grid, even though I am editing the 6th row. The first row has two dates of 9/30/2011 each. The 6th row that I am editing has two dates of 9/30/2011 and 5/28/2011, but both the WebDateChoosers are still being set to 9/30/2011.
Sorry, Maya. The example doesn't work. I can't create a new project for it, because you are using IG 4 v11.1, I am using IG 3.5 v10.3.20103.2134. I am also using this in a master page. Even copying the javascript into my existing project and setting the grid/datechooser the same doesn't work. The only thing I have been able to get to work is the WebDateEditor, but it is displaying the full long date format like Mon Jan 25 00:00:00 CDT. If I could get this format to be mm/dd/yyyy, I can use that.
I'm attaching the sample as requested. Let me know if you have any further need of assistance.
Thanks, Maya. could you provide an example of the second method please?
We set it to the date control's input value.
var hdn=document.getElementById("HiddenPerformancePlanCompletedDate");
--> gets the hidden field on the page
var ChooserId=hdn.value;
--> gets the value that we stored in it
var row=igtbl_getRowById(rowId);
--> Gets the current row we’re on
var currentVal=row.getCell(1).getValue();
--> Gets the value of the cell containing the date time value.
var dateChooser=document.getElementById(ChooserId);
--> Gets the date chooser element from the editing template based on the id we stored in the hidden field.
dateChooser.value=currentVal;
--> sets the value for the date chooser’s input box.
In the meantime I got a better idea on how to get the instance of the date chooser. You can handle it’s initialize client event and from there get the instance of the control:
var dateChooser=null;
function WebDateChooser1_InitializeDateChooser(oDateChooser){
dateChooser=oDateChooser;
}
Then you can put in a global variable and use it in the AfterRowTemplateOpenHandler.
It would be better to use this approach instead of the one i previously suggested.
I understand that in the datecontrol init method we are setting the hidden control value to that of the datechooser. Then in the javascript below we are initializing the hidden control, getting its id, then getting the date from the current row, creating the datechooser var as the hidden date and setting the current row datevalue to the datechooser, which is based on the hidden control.
var hdn=document.getElementById("HiddenPerformancePlanCompletedDate");var ChooserId=hdn.value;var row=igtbl_getRowById(rowId);var currentVal=row.getCell(1).getValue(); var dateChooser=document.getElementById(ChooserId);dateChooser.value=currentVal;dateChooser.Object.inputBox.value=currentVal;
There are 2 things I don't understand. 1) We are taking the value of the rowedittemplate date control, which we have already established isn't reliable, and assigning it to the hidden control and 2) there is nowhere the javascript is assigning that value back to the datecontrol in the edit template? We are simply getting the date from the grid and putting it into the hidden control, which we already did in the date control's init method. I'm confused.....