This is a migrated thread and some comments may be shown as answers.

open window from grid hyperlink column

4 Answers 224 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Aug 2012, 09:45 AM
im wanting to open a radwindow from a hyperlink in a grid. the window provides a way to update the row item, so populates a form within a window with the existing field values.

previously it was being done on rowclick so just worked with loading the fields from the GridDataItem and opening the window via

Me.pBlocks.VisibleOnPageLoad = True


this now needs to be done via a hyperlink on one of the columns.

the hyperlink column is added in the code behind

hlc =

 

New GridHyperLinkColumn

 

Me.uxBlocks.Columns.Add(hlc)

hlc.HeaderText = GetCaption(p.Name)

hlc.UniqueName = p.Name

hlc.DataTextField = p.Name

hlc.DataNavigateUrlFields = {p.Name}

hlc.DataNavigateUrlFormatString =

 

"linktowindow?q={0}"

hlc.Display = True

 

hlc.HeaderStyle.Width =

 

 

Unit.Pixel(170)

hlc.ItemStyle.Wrap =

 

True


could i still call the existing method by getting the GridDataItem when the link is clicked?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Aug 2012, 05:50 AM
Hello,

Try the following code to open RadWindow in onclick of HyperLinkColumn.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem)
 {
   GridDataItem item = (GridDataItem)e.Item;
   HyperLink lnk = (HyperLink)item["UniqueName"].Controls[0];
  lnk.Attributes.Add("onclick", "window.radopen('Window.aspx','RadWindow1'); return false;");
 }
}

Thanks,
Shinu.
0
Mark
Top achievements
Rank 1
answered on 02 Aug 2012, 08:11 AM
thanks

is UniqueName the column name i wish to attribute the hyperlink to ?

when running this i get an error on this line...

Specified argument was out of the range of valid values.
Parameter name: index


Also am i able to pass parameters to the radwindow in this way?
0
Mark
Top achievements
Rank 1
answered on 02 Aug 2012, 08:22 AM
i meant to add the grid is created dynamically in the code behind so i will need to add the hyperlink to the column i want in the code behind...

i think your code may be assuming the hyperlink is set in the front end code for the grid?

0
Mark
Top achievements
Rank 1
answered on 02 Aug 2012, 09:40 AM
Actually i cant get this to work i get an error on clicking the link.

Microsoft JScript runtime error: Object doesn't support property or method 'radopen'

Another method im trying is to use the hyperlinkcolumn urlformatstring to call the window. it works if i pass a single parameter but i need to pass more than one parameter from the grid row.

i try passing a string() parameter list but this doesnt get passed to the javascript function correctly.

as i say if i comment out this line and try the method you sent to open the window i get the error mentioned above. i have a radwindow called pBlocks defined in the page, that i want to appear on clicking a column link with all form fields pre-populated if they exist in the grid row. i also created a separate page for the update form as it seems your method is calling a separate page rather than the radwindow itself?

would you have an example of passing multiple parameters across to the javascript function?

code:
Dim params As String()
            params = GetParameters(info)
 
            For Each p As PropertyInfo In info
 
                If p.Name = "FieldName" Then
 
                    hlc = New GridHyperLinkColumn
                    'hlc.NavigateUrl = "UpdateBlocks.aspx"
                    'hlc.Target = "_blank"
                    Me.uxBlocks.Columns.Add(hlc)
                    hlc.HeaderText = GetCaption(p.Name)
                    hlc.UniqueName = p.Name
                    hlc.DataTextField = p.Name
 
                    hlc.DataNavigateUrlFields = params
                    hlc.DataNavigateUrlFormatString = "JavaScript:openUpdateWindow('{0}');"
                    hlc.Display = True
                    hlc.HeaderStyle.Width = Unit.Pixel(170)
                    hlc.ItemStyle.Wrap = True
                Else
                    gc = New GridBoundColumn
                    Me.uxBlocks.Columns.Add(gc)
                    gc.HeaderStyle.Width = Unit.Pixel(110)
                    gc.HeaderText = GetCaption(p.Name)
                    gc.UniqueName = p.Name
                    gc.DataField = p.Name
                    gc.Display = True
                    gc.ItemStyle.Wrap = True
                End If
 
            Next


Tags
Window
Asked by
Mark
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or