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

ClientSettings-AllowKeyboardNavigation and enter key with dynamic columns fires two commands

1 Answer 116 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Jonathan asked on 18 Feb 2009, 05:50 AM
I have a statically declared Grid as follows:
        <telerik:RadPageView ID="PageView4" runat="server" Width="100%" > 
        <table width="100%" cellpadding="5">  
                <asp:Button ID="btnExport" runat="server" Text="Export Results to Excel" OnClick="btnExport_Click" /> 
                <PagerStyle Mode="NextPrevAndNumeric" /> 
                        <PopUpSettings ScrollBars="None" /> 
                        <div align="center" style="color:darkorange">---------- No Records to Display -----------</div>   

I create columns and bind data to this grid dynamically on the results of a search.

    protected void LoadResources(bool resetPage)  
        //basic or advanced?  
        if (Session["ResourceSearchType"] == "basic")  
            _resources = ResourceService.GetSimpleSearchResults(txtName.Text, Int32.Parse(ddlServiceCategory1.SelectedValue), Int32.Parse(ddlServiceCategory2.SelectedValue), Int32.Parse(ddlServiceCategory3.SelectedValue), Int32.Parse(ddlCityProx.SelectedValue), txtZipCode.Text, txtAddress.Text, Int32.Parse(ddlCityExact.SelectedValue), txtZipCodeExact.Text,  Int32.Parse(ddlLanguage.SelectedValue), Int32.Parse(ddlCity1.SelectedValue), Int32.Parse(ddlCity2.SelectedValue), Int32.Parse(ddlCity3.SelectedValue), txtDescription.Text);  
        else if ((Session["ResourceSearchType"] == "advanced") && (!(txtSqlWhere.Text == string.Empty)))  
            //load the advanced search resources  
            _resources = ResourceService.GetAdvancedSearchResults(txtSqlWhere.Text);  
        //see if we're using the selected columns  
        if (((rdoBasicUseSelectedColumns.Checked == true) && (Session["ResourceSearchType"] == "basic")) ||  
            ((rdoAdvancedUseSelectedColumns.Checked == true) && (Session["ResourceSearchType"] == "advanced")))  
            //Use the default columns  
            ///load the default columns from the database for a search  
            GridButtonColumn _buttonColumn;  
            GridBoundColumn _boundColumn;  
            GridHyperLinkColumn _hyperLinkColumn;  
            _buttonColumn = new GridButtonColumn();  
            _buttonColumn.ButtonType = Telerik.Web.UI.GridButtonColumnType.LinkButton;  
            _buttonColumn.DataTextField = "Name";             
            _buttonColumn.HeaderText = "Name";  
            _buttonColumn.CommandName = "Edit";  
            _buttonColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;  
            _buttonColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;  
            _buttonColumn.SortExpression = "Name";  
            _buttonColumn.HeaderStyle.Width = 150;  
            _boundColumn = new GridBoundColumn();  
            _boundColumn.DataField = "Phone1Description";  
            _boundColumn.HeaderText = "Phone 1";  
            _buttonColumn.SortExpression = "Phone1Description";  
            _boundColumn.HeaderStyle.Width = 100;  
            _boundColumn = new GridBoundColumn();  
            _boundColumn.DataField = "Phone2Description";  
            _boundColumn.HeaderText = "Phone 2";  
            _buttonColumn.SortExpression = "Phone2Description";  
            _boundColumn.HeaderStyle.Width = 100;  
            _boundColumn = new GridBoundColumn();  
            _boundColumn.DataField = "Phone1Description";  
            _boundColumn.HeaderText = "Phone 3";  
            _buttonColumn.SortExpression = "Phone3Description";  
            _boundColumn.HeaderStyle.Width = 100;  
            _boundColumn = new GridBoundColumn();  
            _boundColumn.DataField = "DescriptionSummary";  
            _boundColumn.HeaderText = "DescriptionSummary";  
            _hyperLinkColumn = new GridHyperLinkColumn();  
            _hyperLinkColumn.DataTextField = "WebSiteURL";  
            string[] fields = { "WebSiteURL" };  
            _hyperLinkColumn.DataNavigateUrlFields = fields;  
            _hyperLinkColumn.DataNavigateUrlFormatString = "{0}";  
            _hyperLinkColumn.HeaderStyle.Width = 150;  
            _hyperLinkColumn.HeaderText = "Web Site";  
            _hyperLinkColumn.Target = "_blank";  
            _boundColumn = new GridBoundColumn();  
            _boundColumn.DataField = "MinimumDistance";  
            _boundColumn.HeaderText = "Min Distance";  
            _boundColumn.SortExpression = "MinimumDistance";  
            _boundColumn.HeaderStyle.Width = 80;  
            if (((UserProfile)Session["_userProfile"]).IsAuthorized("Resource - Delete"))  
                _buttonColumn = new GridButtonColumn();  
                _buttonColumn.ButtonType = GridButtonColumnType.ImageButton;  
                _buttonColumn.ConfirmDialogType = GridConfirmDialogType.Classic;  
                _buttonColumn.ConfirmText = "Delete this resource?";  
                _buttonColumn.HeaderText = "Delete";  
                _buttonColumn.HeaderStyle.Width = 60;  
                _buttonColumn.CommandName = "Delete";  
                _buttonColumn.ImageUrl = "./images/delete.gif";  
        radgridResources.MasterTableView.TableLayout = GridTableLayout.Fixed;  
        radgridResources.DataSource = _resources;  
        if (resetPage == true)  
            radgridResources.CurrentPageIndex = 0;  

When the results are bound to the grid I use the down arrow key to navigate to the record of interest and press enter.  Normally on a grid where the columns are declared in the aspx file the


event handler is fired once and I navigate to a page based on the Id of the row.

For some reason the Sort event is getting fired also when the enter key is pressed,  the command argument the first time through the ItemCommand event is "Edit" as is expected and the next time through ItemCommand it is "Sort" after whihc the ItemSorted event is fired also.

I tried setting allowsorting to false and taking out the sorting command handler, and the behaviour gets a little wierder in that the Export to Excel button that is outside the grid is fired in addition to the ItemCommand of the Grid.  Also in this scenario the grid does not recieve focus as specified, so I have to manually click the grid with the mouse before I can navigate with the keyoard.  Could you provide some insight as to the problem?  Thanks

1 Answer, 1 is accepted

Sort by
Nikolay Rusev
Telerik team
answered on 23 Feb 2009, 07:34 AM
Hello Jonathan,

I am afraid that I was unable to replicate your issue locally. For your convenience I am sending you sample application. Please find it attached to this post.

If you are still experience same issue I suggest you to send us runnable application which replicates it via formal support ticket. Thus we'll be able to debug it locally.

Sincerely yours,
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Asked by
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question