I'm filling the grid client side, but I want to make one of the cells a URL link to another site/page. Everything I've tried has not worked its displayed the link as a string not a link to be followed. Is this possible?
Alex,
Thanks for all your help your last suggestion gave me exactly what I was looking for
Hello legalke,
I have used the following code (on HTML button click):
function setValue() { var grid = igtbl_getGridById("UltraWebGrid1"); var cell = grid.Rows.getRow(1).getCell(2); cell.setTargetURL('http://es.infragistics.com'); cell.setValue("Test"); }
function setValue() {
var grid = igtbl_getGridById("UltraWebGrid1");
var cell = grid.Rows.getRow(1).getCell(2);
cell.setTargetURL('http://es.infragistics.com');
cell.setValue("Test");
}
With this code I have set a new hyperlink with value “Test” pointing to our site.
The important thing here is the type of the column it should be set of type Hyperlink or the code will not be applied correctly to grid cell:
<igtbl:UltraGridColumn HeaderText="" Key="Data" EditorControlID="" Hidden="False" Format="" BaseColumnName="Data" FooterText="" Width="50%" Type="HyperLink">
Test this approach and let me know if it is working in your application.
Alex, here's the server side code for the above snippet:
Imports System.Web.Script.Serialization
Partial Public Class WebForm1 Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim confocus, jsfocus As String
confocus = qty.ClientID jsfocus = "window.setTimeout(""try{document.getElementById('" & confocus & "').focus();} catch(e){}"",1000);" ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "TabFocusKey", jsfocus, True)
qty.Attributes.Add("onchange", "BLOCKED SCRIPTQtyChg()") End Sub
<System.Web.Services.WebMethod()> _ Public Shared Function QtyMsg(ByVal qty As String) As String
Dim makejson As New JavaScriptSerializer Dim rows As New List(Of Dictionary(Of String, Object)) Dim row As Dictionary(Of String, Object) Dim dtrow As DataRow Dim dttab As New DataTable() Dim jsonstr As String
jsonstr = "" If IsNumeric(qty) Then Else qty = 0 End If
dttab.Columns.Add("QtyMsg", System.Type.GetType("System.String")) dttab.Columns.Add("QtyLine", System.Type.GetType("System.String"))
dtrow = dttab.NewRow
dtrow(0) = "Quantity Has Been Entered" dtrow(1) = "1"
dttab.Rows.Add(dtrow)
dtrow(0) = "Second Message" dtrow(1) = "2"
For Each dr As DataRow In dttab.Rows row = New Dictionary(Of String, Object)
For Each dc As DataColumn In dttab.Columns row.Add(dc.ColumnName, dr(dc)) Next
rows.Add(row) Next
jsonstr = "{""QtyTable"" : " & makejson.Serialize(rows) & "}" Return jsonstr
End Function
End Class
The code snippet I posted receives a serialized Datatable from a server side Page Method. That's where QtyMsg and QtyLine are coming from. I create a JSON and parse them out and put the values into an UltrawebGrid client side. That's working fine what I want to do is create a "link" from one of those variables that will pass me to another page. I tried to set the TargetURL property on the client side and nothing appeared in the cell.
Can you tell me from where you get “QtyMsg” and “QtyLine” and in what format are these variables returned?
Also what type of column you use and did you set “TargetUrl” property from Server-Side (“InitializeRow” event) or on Client-Side (http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/WebGrid_cell_Object_CSOM.html)?
A runnable sample will be helpful too if you can create one and attach it to this thread.