How to trigger the RadCombo ItemRequest and Default button on "Enter" Key

2 posts, 0 answers
  1. Ramesh kumar Kuppusamy
    Ramesh kumar Kuppusamy avatar
    36 posts
    Member since:
    Apr 2010

    Posted 15 May 2011 Link to this post

    How to trigger the RadCombo ItemRequest and page Default button on "Enter" Key press
    Actual case:

    1. Two combo Boxes   are there -- Issue & Pool

    2. Pools are loaded depending upon the issue selection only

    3. Having the coding in Item request Event for Issue combo box

    4. While I set the enter key as default button to achive the Ok button functionality Item request Event is trigged   -- How can I overcome this problem

     

    Expecting

    1. Two combo Boxes   are there -- Issue & Pool

    2.  Pools are loaded depending upon the issue selection only

    3. Having the coding in Item request Event for Issue combo box

    4. If I place the cursor in issue combo and enter the Enter Key OK button functionality has to carried out.

    Following is the code which I tried for the solution.

     

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
      
    <%@ Register assembly="Telerik.Web.UI" 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">
      
    <head runat="server">
        <title>Untitled Page</title>
        <script language="javascript" type="text/javascript">
      
        var isPost=false;
        var issueDropDownClickStatus=false;
                function onDropDownOpening(sender, args) 
                
                    var ev = args.get_domEvent();  
                    if (ev) 
                    {  
                        var target = ev.target || ev.srcElement;  
                        if (target.id == sender.get_id() + "_Arrow")
                        
                          
                            issueDropDownClickStatus = true;             
                        }  
                    }         
                
                                
                function OnClientItemsRequesting(sender,e)
                {           
                  
                        if(sender.get_appendItems())
                        {
                            e.get_context().CustomText="";                       
                        }
                        else
                        {
                            e.get_context().CustomText=sender.get_text();                        
                        }
                        if(issueDropDownClickStatus == true)
                        {
                            e.get_context().CustomText="";
                             
                        }
                       issueDropDownClickStatus = false;
                }
                  
             
             
           function KeyHandler()
           {debugger;
                if(event.keyCode=='27')
                {
                  
                }
           }
              
              
                 document.onkeydown = KeyHandler;
                  
                </script>
    </head>
    <body>    
         
        <form id="form1" runat="server">
        <div>
         <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            </telerik:RadScriptManager>
            <table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td style="white-space: nowrap">
                        <asp:Label ID="lblIssueTitle" runat="server">Issue:</asp:Label>
                    </td>
                    <td>
                        <telerik:RadComboBox TabIndex="2" ID="drpIssues" runat="server" Height="80px" EnableScreenBoundaryDetection="false"
                            AllowCustomText="false" MarkFirstMatch="true" EnableVirtualScrolling="true" EnableLoadOnDemand="True" ItemsPerRequest="5"
                            ShowMoreResultsBox="true" AutoPostBack="true" HighlightTemplatedItems="true" OnClientItemsRequesting="OnClientItemsRequesting" >
                        </telerik:RadComboBox>
                    </td>
                </tr>
                 <tr>
                    <td style="white-space: nowrap">
                        <asp:Label ID="Label1" runat="server">Pool:</asp:Label>
                    </td>
                    <td>
                        <telerik:RadComboBox TabIndex="2" ID="drpPool" runat="server" Height="80px" EnableScreenBoundaryDetection="false"
                              EnableVirtualScrolling="true" EnableLoadOnDemand="True" ItemsPerRequest="5" AutoPostBack="true">
                        </telerik:RadComboBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="left">
                        <asp:Button ID="ibtnAdd" runat="server" Text="OK" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <telerik:RadGrid id="dgdloan" pagesize="10" runat="server" autogeneratecolumns="False"
                            allowpaging="true" gridlines="None" allowsorting="true">
                                                <ClientSettings>
                                                    <Scrolling UseStaticHeaders="true" AllowScroll="true" />
                                                </ClientSettings>
                                                <MasterTableView DataKeyNames="internal_id" AllowMultiColumnSorting="true" AllowSorting="true">
                                                    <Columns>
                                                        <telerik:GridBoundColumn  HeaderText="Loan Number" ItemStyle-Wrap="false"
                                                            HeaderStyle-Wrap="false">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn HeaderText="Loan Status" ItemStyle-Wrap="false"
                                                            HeaderStyle-Wrap="false" AllowSorting="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn  HeaderText="Loan State" ItemStyle-Wrap="false"
                                                            HeaderStyle-Wrap="false" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn HeaderText="Loan Type" ItemStyle-Wrap="false"
                                                            HeaderStyle-Wrap="false" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn HeaderText="Product Type" ItemStyle-Wrap="false"
                                                            HeaderStyle-Wrap="false" >
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                    </td>
                </tr>
            </table>
      
          
        </div>
        </form>
    </body>
    </html>
    Imports System.Data
    Imports Telerik.Web.UI
      
    Partial Class _Default
        Inherits System.Web.UI.Page
      
        Private mIssueDT As DataTable
      
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                'mIssuePool = AddEmptyRowToIssueMultiple()
            Else
                mIssueDT = DirectCast(ViewState("IssuePoolTable"), DataTable)
            End If
      
            mIssueDT = IssueItem()
            drpIssues.DataTextField = "issue_id"
            drpIssues.DataSource = mIssueDT
            drpIssues.DataBind()
      
        End Sub
      
       
        Private Function IssueItem() As DataTable
      
            Dim setData As New DataTable()
            Dim myDataColumn As DataColumn
      
            setData = New DataTable()
            myDataColumn = New DataColumn()
            myDataColumn.DataType = Type.GetType("System.String")
            myDataColumn.ColumnName = "issue_id"
            setData.Columns.Add(myDataColumn)
      
            Dim newRow1 As DataRow
            newRow1 = setData.NewRow()
            newRow1("issue_id") = "Item1"
            setData.Rows.Add(newRow1)
      
            Dim newRow2 As DataRow
            newRow2 = setData.NewRow()
            newRow2("issue_id") = "Item2"
            setData.Rows.Add(newRow2)
      
            Dim newRow3 As DataRow
            newRow3 = setData.NewRow()
            newRow3("issue_id") = "Item3"
            setData.Rows.Add(newRow3)
      
            Dim newRow4 As DataRow
            newRow4 = setData.NewRow()
            newRow4("issue_id") = "Item4"
            setData.Rows.Add(newRow4)
      
            Dim newRow5 As DataRow
            newRow5 = setData.NewRow()
            newRow5("issue_id") = "Item5"
            setData.Rows.Add(newRow5)
      
            Dim newRow6 As DataRow
            newRow6 = setData.NewRow()
            newRow6("issue_id") = "Item6"
            setData.Rows.Add(newRow6)
      
            Dim newRow7 As DataRow
            newRow7 = setData.NewRow()
            newRow7("issue_id") = "Item7"
            setData.Rows.Add(newRow7)
      
            Dim newRow8 As DataRow
            newRow8 = setData.NewRow()
            newRow8("issue_id") = "Item8"
            setData.Rows.Add(newRow8)
      
            Dim newRow9 As DataRow
            newRow9 = setData.NewRow()
            newRow9("issue_id") = "Item9"
            setData.Rows.Add(newRow9)
      
            Dim newRow10 As DataRow
            newRow10 = setData.NewRow()
            newRow10("issue_id") = "Item10"
            setData.Rows.Add(newRow10)
      
            Dim newRow11 As DataRow
            newRow11 = setData.NewRow()
            newRow11("issue_id") = "Item11"
            setData.Rows.Add(newRow11)
      
            Dim newRow12 As DataRow
            newRow12 = setData.NewRow()
            newRow12("issue_id") = "Item12"
            setData.Rows.Add(newRow12)
      
            Dim newRow13 As DataRow
            newRow13 = setData.NewRow()
            newRow13("issue_id") = "Item13"
            setData.Rows.Add(newRow13)
      
            Return setData
        End Function
         
      
        Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
            ViewState("IssuePoolTable") = mIssueDT
        End Sub
      
      
        Protected Sub drpIssues_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles drpIssues.ItemsRequested
            Dim myRow As DataRow
            Dim setData As New DataTable()
            Dim getData As New DataTable()
            Dim itemOffset As Integer
            Dim endOffset As Integer
            Dim drpIssues As RadComboBox
            drpIssues = DirectCast(o, RadComboBox)
            'getData = GetIssuesByName(e.Context("CustomText").ToString().Trim().ToUpper())
            itemOffset = e.NumberOfItems
            endOffset = Math.Min(itemOffset + 25, getData.Rows.Count)
            e.EndOfItems = endOffset = getData.Rows.Count
            setData.Columns.Add("issue_id")
            setData.Columns.Add("issue_name")
            setData.Columns.Add("issue_status")
            setData.Columns.Add("issue_type")
            setData.Columns.Add("composite_name")
      
            For index As Integer = itemOffset To endOffset - 1
                myRow = setData.NewRow()
                myRow("issue_id") = getData.Rows(index)("issue_id").ToString().Trim()
                myRow("issue_name") = getData.Rows(index)("issue_name").ToString().Trim()
                myRow("issue_status") = getData.Rows(index)("issue_status").ToString().Trim()
                myRow("issue_type") = getData.Rows(index)("issue_type").ToString().Trim()
                myRow("composite_name") = getData.Rows(index)("composite_name").ToString().Trim()
                setData.Rows.Add(myRow)
            Next
      
            drpIssues.DataSource = setData
            drpIssues.DataTextField = "composite_name"
            drpIssues.DataValueField = "issue_id"
            drpIssues.DataBind()
            If getData.Rows.Count = 0 Then
                e.Message = "No Matches"
            Else
                e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, getData.Rows.Count)
            End If
        End Sub
      
        Protected Sub drpIssues_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles drpIssues.SelectedIndexChanged
            Dim PoolData As New DataTable()
            Dim myDataColumn As DataColumn
      
            PoolData = New DataTable()
            myDataColumn = New DataColumn()
            myDataColumn.DataType = Type.GetType("System.String")
            myDataColumn.ColumnName = "Pool_id"
            PoolData.Columns.Add(myDataColumn)
      
            Select Case drpIssues.SelectedItem.Text.Trim()
                Case "Item1"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value1"
                    PoolData.Rows.Add(newRow1)
      
                Case "Item2"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value2"
                    PoolData.Rows.Add(newRow1)
      
                Case "Item3"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value3"
                    PoolData.Rows.Add(newRow1)
                Case "Item4"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value4"
                    PoolData.Rows.Add(newRow1)
                Case "Item5"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value5"
                    PoolData.Rows.Add(newRow1)
                Case "Item6"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value6"
                    PoolData.Rows.Add(newRow1)
                Case "Item7"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value7"
                    PoolData.Rows.Add(newRow1)
                Case "Item8"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value8"
                    PoolData.Rows.Add(newRow1)
      
                Case "Item9"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value9"
                    PoolData.Rows.Add(newRow1)
      
                Case "Item10"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value10"
                    PoolData.Rows.Add(newRow1)
                Case "Item11"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value11"
                    PoolData.Rows.Add(newRow1)
                Case "Item12"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value12"
                    PoolData.Rows.Add(newRow1)
                Case "Item13"
                    Dim newRow1 As DataRow
                    newRow1 = PoolData.NewRow()
                    newRow1("Pool_id") = "Value13"
                    PoolData.Rows.Add(newRow1)
            End Select
      
      
            drpPool.DataTextField = "Pool_id"
            drpPool.DataSource = PoolData
            drpPool.DataBind()
      
        End Sub
    End Class

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 19 May 2011 Link to this post

    Hi Ramesh,

    Could you specify what exactly do you mean by : "If I place the cursor in issue combo and enter the Enter Key OK button functionality has to carried out."

    I've tested your scenario and it was working as expected, the ItemRequested event of the "issue" combobox is fired only when you use the virtual scrolling.

    Best wishes,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top