Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
137
Extending WebGrid to Automatically Render Grid Editors
posted
We currently have an extended webgrid which we do several things onInitialize etc.  For this grid I would like to set up in cell editors such as a webDateChooser, a dateTimeMask and an infragistics TextBox.  This works fine when putting the controls on the page and binding columns to the control id's.  However, I would like the grid itself to render all of these controls automatically so that other developers will not have to worry about adding extra controls and binding the columns.  I am overriding the Render control to try and render these three controls to the page.  It seems to be rendering to the page correctly but does not seem to be functional.  The webDateChooser for example does not contain the drop down arrow and is not masked via the javascript.  The following methods have been attempted.

Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
mdmkGridDateMask.RenderControl(output) 
mtmkGridTimeMask.RenderControl(output)
mtxtGridTextArea.RenderControl(output)
MyBase.Render(output)
End Sub

Also, me.RenderChildren was also considered but the me.Controls collection seems to be empty when the Render function is called.

Private sub onInit(...) Handles Me.Init
//Initialize and add control to control collection here
end sub

Private Sub CustomizeColumns()
Dim colColumn As UltraGridColumn

For Each colColumn In myGrid.Columns
Select Case colColumn.BaseColumnName
Case "TestColName
"
colColumn.AllowUpdate = AllowUpdate.Yes
colColumn.DataType =
"System.DateTime"
colColumn.Type = ColumnType.Custom
colColumn.EditorControlID = myGrid.GridDateMask.UniqueID

End Select
Next
End Sub

Are there any suggestions about how I can get this to work properly?

Thanks,
KyleL

Parents
No Data
Reply
  • 137
    posted

    The following render function works for adding the controls to the page and allowing the grid to use them as grid editors.

    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
    Me.Controls.Add(mdmkGridDateMask)
    Me.Controls.Add(mtmkGridTimeMask)
    Me.Controls.Add(mtxtGridTextArea)
    MyBase.RenderChildren(output)
    MyBase.Render(output)
    End Sub

    However, the editors are visible on the page until the grid is clicked to edit.  At that time the editor is not visible and the cell will allow for editing with the control.  Also, ClientID must be used when setting the column editor id.  Any Ideas on how to stop the controls from displaying visibly on the page?  The visible property can not be set to false otherwise the grid will not pick up the editor.

     KyleL

Children
No Data