HI, I have a Prometheus RadGrid that I build dynamically when a user click on a button. With the Prometheus Ajax, I clear all the colunm definition (depending on the button clicked the colunm change) and recreate it. On one situation, I have a template column that display a icon or a blank icon dépending on boolean value. All work good, the first time the grid are created the column header template and the item template work good. But if I click on one item in the grid, the rad ajax update some textbox, but I lost the header and item template.
Any suggestion?
The CreeGridAct are called after a ajaxified postback button click
Create the grid and template dynamically:
Any suggestion?
The CreeGridAct are called after a ajaxified postback button click
Create the grid and template dynamically:
Private Sub CreeGridAct() |
Dim column1 As GridBoundColumn |
Dim ColumnTmpl As GridTemplateColumn |
EffaceChamps() |
RadGridUsager.Skin = "WebBlue" |
RadGridUsager.Width = Unit.Pixel(450) |
RadGridUsager.PageSize = 15 |
RadGridUsager.AllowPaging = True |
RadGridUsager.AllowSorting = True |
RadGridUsager.GridLines = GridLines.Horizontal |
RadGridUsager.AllowMultiRowSelection = True |
RadGridUsager.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced |
RadGridUsager.AutoGenerateColumns = False |
RadGridUsager.GroupingEnabled = False |
RadGridUsager.ShowGroupPanel = False |
RadGridUsager.ShowFooter = True |
RadGridUsager.ClientSettings.AllowDragToGroup = False |
RadGridUsager.ClientSettings.AllowColumnsReorder = True |
RadGridUsager.ClientSettings.EnablePostBackOnRowClick = True |
RadGridUsager.ClientSettings.ApplyStylesOnClient = True |
RadGridUsager.ClientSettings.Selecting.AllowRowSelect = True |
RadGridUsager.MasterTableView.PageSize = 15 |
RadGridUsager.MasterTableView.Width = Unit.Percentage(100) |
RadGridUsager.MasterTableView.Columns.Clear() |
'Creation des colones pour cet affichage |
column1 = New GridBoundColumn |
RadGridUsager.MasterTableView.Columns.Add(column1) |
column1.DataField = "Usager" |
column1.HeaderText = "Usager" |
column1.Visible = False |
column1 = New GridBoundColumn |
RadGridUsager.MasterTableView.Columns.Add(column1) |
column1.DataField = "Nom" |
column1.HeaderText = "Nom" |
column1 = New GridBoundColumn |
RadGridUsager.MasterTableView.Columns.Add(column1) |
column1.DataField = "Compagnie" |
column1.HeaderText = "Compagnie" |
column1 = New GridBoundColumn |
RadGridUsager.MasterTableView.Columns.Add(column1) |
column1.DataField = "Ville" |
column1.HeaderText = "Ville" |
column1 = New GridBoundColumn |
RadGridUsager.MasterTableView.Columns.Add(column1) |
column1.DataField = "Telephone" |
column1.HeaderText = "Téléphone" |
ColumnTmpl = New GridTemplateColumn |
RadGridUsager.MasterTableView.Columns.Add(ColumnTmpl) |
ColumnTmpl.UniqueName = "Suspendu" |
ColumnTmpl.Groupable = False |
ColumnTmpl.SortExpression = "Suspendu" |
ColumnTmpl.HeaderStyle.Width = 20 |
ColumnTmpl.HeaderTemplate = New SusHeaderTemplate |
ColumnTmpl.ItemTemplate = New SusItemTemplate |
RadGridUsager.Rebind() |
End Sub |
Private Class SusHeaderTemplate |
Implements ITemplate |
Public Sub New() |
MyBase.New() |
End Sub |
Protected imgSus As Image |
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn |
imgSus = New Image |
imgSus.ImageUrl = "images/Misc/suspendu.gif" |
container.Controls.Add(imgSus) |
End Sub |
End Class |
Private Class SusItemTemplate |
Implements ITemplate |
Public Sub New() |
MyBase.New() |
End Sub |
Protected imgSus As Image |
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements ITemplate.InstantiateIn |
imgSus = New Image |
imgSus.ImageUrl = "images/Misc/Blank.gif" |
container.Controls.Add(imgSus) |
AddHandler imgSus.DataBinding, AddressOf Me.imgSus_DataBinding |
End Sub |
Private Sub imgSus_DataBinding(ByVal sender As Object, ByVal e As EventArgs) |
Dim imgSus As Image = CType(sender, Image) |
Dim container As GridDataItem = CType(imgSus.NamingContainer, GridDataItem) |
If Convert.ToBoolean(DataBinder.Eval(container.DataItem, "Suspendu")) = True Then |
imgSus.ImageUrl = "images/Misc/suspendu.gif" |
Else |
imgSus.ImageUrl = "images/Misc/blank.gif" |
End If |
End Sub |
End Class |