Dear reader,
I'm having trouble setting the focus on a radtreeview after doing a serverside action.
The function of this page:
Someone searches a phrase and presses "zoek". Grid gvZoeken gets filled with the results.
Clicking the linkbutton in the grid filles the plnTeksten with the desired text and the desired node in the tree gets selected (abusing the linkbuttons CommandArgument for that.). I also want the page to be scrolled to the treeview thats below the searchgrid.
* Registering a clientscript in the RadScriptManager
* removing the formdecorator
* All kinds of examples in this forum and the on-line help.
What does work, but is not the desired solution:
Putting a visible textbox on the page and focusing it with RadAjaxManager1.FocusControl(Textbox1.ClientID)
Anyone got idea's?
ASPX:
VB
I'm having trouble setting the focus on a radtreeview after doing a serverside action.
The function of this page:
Someone searches a phrase and presses "zoek". Grid gvZoeken gets filled with the results.
Clicking the linkbutton in the grid filles the plnTeksten with the desired text and the desired node in the tree gets selected (abusing the linkbuttons CommandArgument for that.). I also want the page to be scrolled to the treeview thats below the searchgrid.
Things that didnt work:
* RadAjaxManager1.FocusControl(RadTreeView1.ClientID)
* Registering a clientscript in the RadScriptManager
* removing the formdecorator
* All kinds of examples in this forum and the on-line help.
What does work, but is not the desired solution:
Putting a visible textbox on the page and focusing it with RadAjaxManager1.FocusControl(Textbox1.ClientID)
Anyone got idea's?
ASPX:
| <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Dossier.aspx.vb" Inherits="Dossiers_Dossier" %> | |
| <%@ Register Assembly="Telerik.Web.UI, Version=2009.1.527.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" | |
| Namespace="Telerik.Web.UI" TagPrefix="telerik" %> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head runat="server"> | |
| <title>Dossier</title> | |
| <link href="../css/StyleSheet.css" rel="stylesheet" type="text/css" /> | |
| </head> | |
| <body> | |
| <form id="form1" runat="server"> | |
| <div> | |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> | |
| </telerik:RadScriptManager> | |
| <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Sunset" /> | |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> | |
| <AjaxSettings> | |
| <telerik:AjaxSetting AjaxControlID="RadTreeView1"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="RadTreeView1" /> | |
| <telerik:AjaxUpdatedControl ControlID="pnlTeksten" /> | |
| <telerik:AjaxUpdatedControl ControlID="pnlDossier" /> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
| <telerik:AjaxSetting AjaxControlID="gvZoeken"> | |
| <UpdatedControls> | |
| <telerik:AjaxUpdatedControl ControlID="RadTreeView1" /> | |
| <telerik:AjaxUpdatedControl ControlID="pnlTeksten" /> | |
| <telerik:AjaxUpdatedControl ControlID="pnlDossier" /> | |
| </UpdatedControls> | |
| </telerik:AjaxSetting> | |
| </AjaxSettings> | |
| </telerik:RadAjaxManager> | |
| <table> | |
| <tr> | |
| <td> | |
| <telerik:RadMenu ID="RadMenu1" runat="server" Skin="Sunset"> | |
| <Items> | |
| <telerik:RadMenuItem Text="Terug" NavigateUrl="Default.aspx" /> | |
| </Items> | |
| </telerik:RadMenu> | |
| </td> | |
| <td> | |
| <h1> | |
| <asp:Label ID="lblTitel" runat="server"></asp:Label></h1> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td colspan='2'> | |
| <table> | |
| <tr> | |
| <td> | |
| Zoek in dossier: | |
| </td> | |
| <td> | |
| <asp:TextBox ID="tbZoekterm" runat="server"></asp:TextBox><asp:Button ID="butZoek" | |
| runat="server" Text="Zoek" /><br /> | |
| <asp:Label ID="lblEror" runat="server" ForeColor="Red"></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| <td> | |
| <telerik:RadGrid ID="gvZoeken" runat="server" AllowPaging="True" AllowSorting="True" | |
| AutoGenerateColumns="False" GridLines="None" Skin="Sunset" DataSourceID="SqlDataSource2"> | |
| <PagerStyle Mode="NextPrevAndNumeric" NextPageToolTip="Volgende pagina" PagerTextFormat="Verander pagina: {4} &nbsp;Getoonde pagina {0} van {1}, rijen {2} t/m {3} van {5}." | |
| PrevPageToolTip="Vorige pagina" FirstPageToolTip="Eerste pagina" LastPageToolTip="Laatste pagina" /> | |
| <MasterTableView DataKeyNames="TekstNr" NoMasterRecordsText="Geen resultaten gevonden." | |
| DataSourceID="SqlDataSource2" PageSize="10"> | |
| <Columns> | |
| <telerik:GridTemplateColumn> | |
| <ItemTemplate> | |
| <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Highlight(tbZoekterm.Text,Eval("Titel")) %>' | |
| CommandArgument='<%# Eval("TekstNr") %>' OnClick="ZoekItemClick">LinkButton</asp:LinkButton> | |
| <br /> | |
| <br /> | |
| <asp:Literal ID="Literal1" runat="server" Text='<%# Highlight(tbZoekterm.Text,Eval("tekst"))%>'></asp:Literal> | |
| </ItemTemplate> | |
| </telerik:GridTemplateColumn> | |
| </Columns> | |
| </MasterTableView> | |
| <ClientSettings EnableRowHoverStyle="true" /> | |
| <SortingSettings SortedAscToolTip="Oplopend gesoteerd" SortedDescToolTip="Aflopend gesorteerd" | |
| SortToolTip="Klik hier om te sorteren" /> | |
| </telerik:RadGrid> | |
| <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:DB %>" | |
| ProviderName="System.Data.SqlClient" SelectCommand="Zoek_in_dossier" SelectCommandType="StoredProcedure" | |
| runat="server"> | |
| <SelectParameters> | |
| <asp:QueryStringParameter Name="dossiernr" QueryStringField="dId" Type="Int32" /> | |
| <asp:FormParameter Name="Zoekterm" FormField="tbZoekterm" Type="String" /> | |
| </SelectParameters> | |
| </asp:SqlDataSource> | |
| </td> | |
| </tr> | |
| </table> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td valign="top"> | |
| <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Sunset" EnableDragAndDrop="False" | |
| EnableDragAndDropBetweenNodes="False" AllowNodeEditing="False" DataFieldID="Tekstnr" | |
| DataFieldParentID="ParentID" DataSourceID="SqlDataSource1" DataTextField="Titel" | |
| DataValueField="Tekstnr"> | |
| </telerik:RadTreeView> | |
| <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:DB %>" | |
| ProviderName="System.Data.SqlClient" SelectCommand="GET_DOSSIER_TEKSTEN" SelectCommandType="StoredProcedure" | |
| runat="server"> | |
| <SelectParameters> | |
| <asp:QueryStringParameter Name="dossiernr" QueryStringField="dId" Type="Int32" /> | |
| </SelectParameters> | |
| </asp:SqlDataSource> | |
| </td> | |
| <td valign="top"> | |
| <asp:Panel ID="pnlDossier" runat="server"> | |
| <table> | |
| <tr> | |
| <td> | |
| Dossier titel: | |
| </td> | |
| <td> | |
| <asp:Label ID="lblDossierTitel" runat="server"></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| Instituut: | |
| </td> | |
| <td> | |
| <asp:Label ID="lblInstituut" runat="server"></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| Versie: | |
| </td> | |
| <td> | |
| <asp:Label ID="lblVersie" runat="server"></asp:Label> | |
| </td> | |
| </tr> | |
| </table> | |
| </asp:Panel> | |
| <asp:Panel ID="pnlTeksten" runat="server" Visible="false"> | |
| <table> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| <td> | |
| <asp:Label ID="lblTitel2" runat="server"></asp:Label> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| <td> | |
| Samenvatting:<br /> | |
| <asp:Label ID="lblSamenvatting" runat="server" /> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| <td> | |
| Verdieping:<br /> | |
| <asp:Label ID="lblVerdieping" runat="server" /> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| <td> | |
| Detaillering:<br /> | |
| <asp:Label ID="lblDetaillering" runat="server" /> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td> | |
| | |
| </td> | |
| </tr> | |
| </table> | |
| </asp:Panel> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| </form> | |
| </body> | |
| </html> | |
| Imports Telerik.Web.UI | |
| Partial Class Dossiers_Dossier | |
| Inherits System.Web.UI.Page | |
| Dim dossierID As Integer | |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load | |
| dossierID = Request("did") | |
| End Sub | |
| Protected Sub RadTreeView1_NodeDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeDataBound | |
| 'Expand the parent | |
| If e.Node.Value = "0" Then | |
| e.Node.Expanded = True | |
| End If | |
| End Sub | |
| Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeClick | |
| 'Selected node changed | |
| NodeSelectieveranderd(e.Node) | |
| End Sub | |
| Sub NodeSelectieveranderd(ByVal n As RadTreeNode) | |
| If n.Value = "0" Then 'new selectednode is rootnode | |
| pnlDossier.Visible = True | |
| pnlTeksten.Visible = False | |
| lblTitel2.Text = "" | |
| lblSamenvatting.Text = "" | |
| lblVerdieping.Text = "" | |
| lblDetaillering.Text = "" | |
| Else 'childnode | |
| pnlDossier.Visible = False | |
| pnlTeksten.Visible = True | |
| 'fill pnlTeksten | |
| lblTitel2.Text = "test" | |
| n.ExpandParentNodes() | |
| End If | |
| End Sub | |
| 'Find and highlight words that match the searchvalue | |
| Public Function Highlight(ByVal Search_Str As String, ByVal InputTxt As String) As String | |
| ' Setup the regular expression and add the Or operator. | |
| Dim RegExp As New Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase) | |
| ' Highlight keywords by calling the delegate each time a keyword is found. | |
| Return RegExp.Replace(InputTxt, New MatchEvaluator(AddressOf ReplaceKeyWords)) | |
| ' Set the RegExp to null. | |
| End Function | |
| 'Highlight the keywords | |
| Public Function ReplaceKeyWords(ByVal m As Match) As String | |
| Return "<span class='Highlight'>" + m.Value + "</span>" | |
| End Function | |
| 'Linkbutton in searchgrid is clicked | |
| Protected Sub ZoekItemClick(ByVal sender As Object, ByVal e As System.EventArgs) | |
| Dim lb As LinkButton = CType(sender, LinkButton) | |
| RadTreeView1.FindNodeByValue(lb.CommandArgument).Selected = True | |
| NodeSelectieveranderd(RadTreeView1.SelectedNode) | |
| RadAjaxManager1.FocusControl(RadTreeView1.ClientID) | |
| End Sub | |
| End Class |