PDA

View Full Version : dynamic links



gmarcinari
Mar 09, 2015, 2:32 PM
I'm generating a grid by the code behind of dynamic way, this grid have HyperLinkColumn and would like to know a way to spend links so that each line had a different link. If I put the link dataIndex as it will only bring the link, I need to show any text with different link on each line.

lrossism
Mar 09, 2015, 7:54 PM
Please, take a look on example http://examples.ext.net/#/GridPanel/ColumnModel/HyperlinkColumn/

or post your code for more help...

gmarcinari
Mar 09, 2015, 8:34 PM
Thank you for answering.

my research in the database returns more than one link, so when I do "for" to mount the column, it passes once and assigns the same link to the entire column.

Code:


Dim dt As New DataTable
Dim list As New List(Of ColumnBase)
Dim listContOcorr As New List(Of Object)

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
buildGrid()
End If

End Sub

Public Sub buildGrid()

dt = SearchStrore()

Dim sizeDt As Integer
Dim numeroModels As String = "1"

sizeDt = dt.Columns.Count

For i As Integer = 0 To sizeDt - 1
Me.buildModel(dt.Columns(i).ColumnName, i)
Next

gridOcorrenciaMes.Reconfigure(list)

Me.buildStore()

End Sub

Public Sub AddField(ByVal field As ModelField)

Me.storeOcorrencia.Model(0).Fields.Add(field)

End Sub

Public Sub buildModel(ByVal nomeModel As String, ByVal indice As Integer)

Me.AddField(New ModelField(nomeModel.ToString))

Dim colunaMes As String = nomeModel.Split("/")(0)

Dim ano As String
Dim mes As String

ano = nomeModel.Split("/")(0)
mes = nomeModel.Split("/")(1)

Dim coluna As New Ext.Net.HyperlinkColumn
coluna.Width = "70"
coluna.Align = Alignment.Center
coluna.ID = "Col" & nomeModel.Replace("/", "")
coluna.Text = nomeModel
coluna.DataIndex = nomeModel
coluna.Filterable = True

'coluna.HrefPattern = here I get my link

list.Add(coluna)

End Sub

Public Sub buildStore()

Me.storeOcorrencia.DataSource = dt
Me.storeOcorrencia.DataBind()

End Sub

lrossism
Mar 11, 2015, 1:01 PM
the "HyperLinkColumn" component enables the configuration of one link. Try using a "CustomColumn", see example http://examples.ext.net/#/GridPanel/Miscellaneous/Custom_Column/ and manually create links from html tags.

gmarcinari
May 18, 2015, 2:48 PM
I created a custom column , as you said, with one record per link and used the dataindexHref to assign links to the HyperLinkColumn