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

linkbutton of header column in grid

12 Answers 540 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jols
Top achievements
Rank 2
Jols asked on 26 Mar 2009, 10:14 AM
hello to all,
 
                thanks again to sir shinu!
 
               i would like ask again a help to all expert of telerik control, coz i been configuring the grid to have a header column with linkbutton or hyperlink button, i already have a group header in my grid but my problem is i can't put a link to it..here's my codes

<telerik:RadGrid ID="RDGridResponse" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        GridLines="None" Skin="WebBlue" ShowGroupPanel="True" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False" Font-Size="Small" Font-Strikeout="False" Font-Underline="False" >
                        <MasterTableView Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False" Font-Size="X-Small" Font-Strikeout="False" Font-Underline="False">
                            <RowIndicatorColumn>
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="Response" GroupByExpression="Response"
                                    UniqueName="ResponseName">
                                    <ItemStyle Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False"
                                        Font-Size="Small" Font-Strikeout="False" Font-Underline="False" Wrap="True" />
                                </telerik:GridBoundColumn>
                                
                            </Columns>
                            <GroupByExpressions>
                                 <telerik:GridGroupByExpression>
                                      <SelectFields>
                                          <telerik:GridGroupByField FieldName ="MemberName" FieldAlias="Name"/>
                                          <telerik:GridGroupByField FieldName ="ResponseDate" FieldAlias ="Date" FormatString="" HeaderText="" />
                                      </SelectFields>
                                      <GroupByFields>
                                         <telerik:GridGroupByField FieldName ="." FieldAlias= "." FormatString ="" HeaderText= "" />
                                         <telerik:GridGroupByField FieldName ="Response" FieldAlias="Response" />
                                      </GroupByFields>
                                 </telerik:GridGroupByExpression>
                            </GroupByExpressions>
                        </MasterTableView>
                        <ClientSettings AllowDragToGroup="True">
                            <Selecting AllowRowSelect="True" />
                        </ClientSettings>
                        <FilterMenu EnableTheming="True" Skin="Vista">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                        </FilterMenu>
                    </telerik:RadGrid>
           
in the groupbyfields tag to gridbroupbyfield fieldname "Response" i want it to be a hyperlink or linkbutton either of two how can i configure it or how i can do that..please help

sample/codes is highly appreciated

thanks to all   
                

12 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Mar 2009, 10:59 AM
Hello Jols,

Try adding a LinkButton to the control collection of the groupheader and then add an onClick attribute for the LinkButton and set the LinkButton text as the group header text.  Check out the code below to understand better:
c#:
 
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))  
        {  
            string strtxt = groupHeader.DataCell.Text; // accessing the groupheader text  
            LinkButton hyperlnk = new LinkButton(); // creting new link  
            hyperlnk.Text = strtxt;  
            groupHeader.DataCell.Controls.Clear();  
            groupHeader.DataCell.Controls.Add(hyperlnk); // adding link to the groupheader  
         }  
    } 

Thanks
Princy.
0
Jols
Top achievements
Rank 2
answered on 26 Mar 2009, 11:13 AM
sir
    thanks for the reply but i have an error while pasting your codes it says the type or namespace 'GridGroupHeaderItem could not be found ' and the GridItemtype.. what is missing on my codes.?
0
Jols
Top achievements
Rank 2
answered on 26 Mar 2009, 11:18 AM
sir princy

             its work already only i missed there is the using telerik.web.ui. how can get the value on that linkbutton so i could the pass to other page. in short a parameter value upon clicking on that linkbutton..sir need help again..

thanks
0
Jols
Top achievements
Rank 2
answered on 26 Mar 2009, 12:21 PM
Sir,

        i dont know how to add an attribute to the control collection for the linkbutton, actually this is my very first time to create a web.  please help
0
Princy
Top achievements
Rank 2
answered on 27 Mar 2009, 03:48 AM
Hi Jols,

Give a try with the following code snippet and see if it helps.

CS:
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
 
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
        { 
            string strtxt = groupHeader.DataCell.Text; // accessing the groupheader text   
            LinkButton hyperlnk = new LinkButton(); // creting new link   
            hyperlnk.Text = strtxt;
            //add attribut here
            hyperlnk.Attributes.Add("Style""font-family:Garamond"); 
            groupHeader.DataCell.Controls.Clear(); 
            groupHeader.DataCell.Controls.Add(hyperlnk); // adding link to the groupheader   
        }   
        
        
    } 


Thanks
Princy
0
Jols
Top achievements
Rank 2
answered on 27 Mar 2009, 06:34 AM
Sir,

         how about an onclick event on the radgrid1_prerender so i could popup a panel when user click the hearder column of the grid with hyperlink then pass a parameter value as my ID so that my panel with grid also can load the data? please help again sir..


thanks and more power
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2009, 08:13 AM
Hi Jols,

Try the following code snippet to add an OnClick client event to hyperlink in the GridGroupHeader. Then in the client click event you can show/hide the panel accordingly.

CS:
 
 
  protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
        { 
            string strtxt = groupHeader.DataCell.Text; // accessing the groupheader text    
            LinkButton hyperlnk = new LinkButton(); // creting new link    
            hyperlnk.Text = strtxt; 
            //access the Group index of clicked row 
            string strGroupIndex = groupHeader.GroupIndex; 
            //add attribut here 
            hyperlnk.Attributes.Add("OnClick""Show('" + strGroupIndex + "');"); 
            groupHeader.DataCell.Controls.Clear(); 
            groupHeader.DataCell.Controls.Add(hyperlnk); // adding link to the groupheader    
        }    
    } 

JS:
 
<script type="text/javascript" > 
  function Show(GroupIndex) 
  { 
   alert(GroupIndex) 
  } 
</script> 


Thanks
Shinu

0
Jols
Top achievements
Rank 2
answered on 27 Mar 2009, 09:42 AM
sir kindly check this client event of mine

function panel()
{
 var getpanel=document.getElementByID('PnlDetails');
 alert(getpanel);

}

is this correct sir?
0
Shinu
Top achievements
Rank 2
answered on 27 Mar 2009, 11:26 AM
Hi Jols,

Here is the code snippet to show a Panel on clicking the hyperlink.

Try hiding the Panel initially using the CssClass as shown below.

ASPX:
 
<asp:Panel ID="PnlDetails" CssClass="PanelStyle"  runat="server" > 
             My Panel 
            <telerik:RadGrid ID="RadGrid2" runat="server"
            </telerik:RadGrid> 

Hide the Panel initially using CssStyle
style.css:
 
 
<head runat="server"
    <title>Untitled Page</title> 
    <style type="text/css" > 
      .PanelStyle 
      { 
       display:none
      } 
    </style> 
</head> 


CS:
 
 
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
        { 
            string strtxt = groupHeader.DataCell.Text; // accessing the groupheader text    
            LinkButton hyperlnk = new LinkButton(); // creting new link    
            hyperlnk.Text = strtxt; 
            //access the Group index of clicked row 
            string strGroupIndex = groupHeader.GroupIndex; 
            //add attribut here 
            hyperlnk.Attributes.Add("OnClick""Show(); return false;"); 
            groupHeader.DataCell.Controls.Clear(); 
            groupHeader.DataCell.Controls.Add(hyperlnk); // adding link to the groupheader    
        }    
    } 

Client side code to show the panel.
JS:
 
 
 
<script type="text/javascript" > 
  function Show() 
  { 
   var getpanel=document.getElementById('PnlDetails'); 
    getpanel.style.display='block'
     
  } 
</script> 


Thanks
Shinu
0
Jols
Top achievements
Rank 2
answered on 27 Mar 2009, 12:06 PM
sir thank so much for the answer, sir is there any way to hide the footer from the radwindow or radwindowmanager coz when i launch the radwindow, below it appears the page plus the value coming from the javascript its look like this;

Mypage.aspx?accountnumber=123

how can i hide that sir. so the user wont see any value from that page that being launch..

thanks and more power

sample/codes is highly appreciated
0
Shinu
Top achievements
Rank 2
answered on 30 Mar 2009, 05:44 AM

Hello Jols,

 

Try setting VisibleStatusBar property of RadWindowManager to false in order to hide the statusbar which contains information (status, url and parameter passed to RadWindow) about the content window.

ASPX:

<telerik:RadWindowManager ID="RadWindowManager1" VisibleStatusbar="false" runat="server"
<Windows> 
    . . . 
</Windows> 
</telerik:RadWindowManager>    

Thanks,

Shinu.

0
Jols
Top achievements
Rank 2
answered on 31 Mar 2009, 07:50 AM
Sir Shinu,
     Good Day!
            thanks you so much for the help its work perfectly, but i got another problem when i used a linkbutton inside my grid and put a javascript on the Onclick event of the link button to show a radwindow it wont work i dont know how fix it .. anyway here's my source code..please help..

Scenario: the grid has a title link button that when the user click the title or any title on the grid a window will popup.

<script type="text/javascript">  
   function openRadWindow()  
       {  
       var accNumber= document.getElementById("linkTitle").value;  
      var oWnd = radopen("CHSTransactional.aspx?accoutnumber=" +accNumber + '&Cardno=' + cardNumber);  // Set the url  
       oWnd.center();  
       oWnd.set_modal(true);
       }  
</script> 


<telerik:RadGrid ID="EmailGrid" runat="server" AutoGenerateColumns="False" GridLines="None"
                    Skin="WebBlue" Width="696px" OnItemCommand="EmailGrid_ItemCommand" OnPreRender="EmailGrid_PreRender">
                    <MasterTableView DataKeyNames ="fxRequestID">
                        <Columns>
                          
                          <telerik:GridTemplateColumn HeaderText="&#160;Knowledge Base" UniqueName="TemplateColumn" ItemStyle-HorizontalAlign ="Left" >
                              <ItemTemplate>
                                 <table cellpadding="1" cellspacing="0" style="cursor: default;">
                                    <tr>
                                      <td style="border: 0px; text-align: left;">
                                             <span> Title:
                                             <asp:LinkButton Text ='<%# Eval("Title") %> ' CommandName ="Select" runat ="server" ID="linkTitle"  Onclick="openRadWindow();"                   >     //this is not working i'm puzzled why it wont work this way                         
                                             </asp:LinkButton>  
                                             </span>
                                          <br/>
                                             <tr>
                                                <td style="border: 0px; text-align: left;">
                                                  <span>
                                                     <%# Eval("Description") %>
                                                  </span>
                                                </td>  
                                             </tr>
                                     </td>
                                    </tr>   
                                  </table>
                              </ItemTemplate>
                                
                          </telerik:GridTemplateColumn>
                          
                        </Columns>
                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn>
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                    </MasterTableView>
                    <FilterMenu EnableTheming="True" Skin="Web20">
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </FilterMenu>
                </telerik:RadGrid></asp:Panel>

sample/codes is highly appreciated
Tags
Grid
Asked by
Jols
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Jols
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or