• Home
  • About
  • Resume

Selectively change cell type in Infragistics UltraWebGrid

By , 04/20/2010 11:28 AM

When you design columns for UltraWebGrid, one of the settings available to you is Column Type. For example you can set it to Button, and all cells within the column will render and behave as HTML buttons. Other options available such as Check Box or Hyperlink.

But what if you want some of the column cells to be of a different type? For example some of cells aren’t supposed to be links, but plain text instead? The solution is to set Column Type of those cell thru code. Consider following example:

Protected Sub xmyGrid_InitializeRow(ByVal sender As Object, ByVal e As RowEventArgs) Handles xmyGrid.InitializeRow
    If e.Row.Index > 0 Then
        e.Row.Cells.FromKey("LINK_CELL).TargetURL = "http://mysite.com?ID=" & e.Row.Cells.FromKey("LINK_ID)
        e.Row.Cells.FromKey("OBJ_NAME").Column.Type = ColumnType.NotSet
    End If
end sub

Above is a handler for UltraWebGrid’s InitializeRow event. It checks if a row is a first row in the grid and if so – sets its column type to “NotSet” effectively removing “Hyperlink” type set at design time. And even though it references type of entire column – the change applies only to the current cell.

5 Responses to “Selectively change cell type in Infragistics UltraWebGrid”

  1. zee says:

    do you have any solution: if one of the column cell needs to be a checkbox and other cell in the same column needs to be a button?

  2. Yuriy says:

    @zee I don’t think this is possible via standard grid column types. You may have to resort to custom HTML, e.g. in the example above:

    e.Row.Cells.FromKey("OBJ_NAME").value = "<input type='chekbox'>"
    e.Row.Cells.FromKey("OBJ_NAME").value = "<input type='button'>"
  3. Sachin says:

    @Yuriy , your solution worked like a charm.

  4. Tyler says:

    Any idea how to access the button via server side code?

  5. Yuriy says:

    @Tyler button described above in reply to @zee will be a client-side only button. What scenario do you need access button server-side for?

Leave a Reply

Panorama Theme by Themocracy