简体   繁体   中英

Telerik RadGrid Does NOT select Row on LEFT CLICK when the cell value is a link

包含链接的网格单元

I have custom columns in my telerik rad grid for Asp.net and some of those display links (A href='...').

links work fine.

the PROBLEM is that the grid DOES NOT SELECT the ROW of the cell that I clicked ONLY when I click on a cell that has a link (rather than plain text).

normally the grid DOES SELECT the row without any trouble when a user clicks on a regular cell .

this only happens when the cell content is a link.

any idea to get around this? please.

Code:

1 - The link behind the link (that goes into the grid cell)

<a href="#" onclick="commandManager(event, otherParameters);">Cotgrave</a>

2 - The code that's invoked.

    function commandManager(clickEventArgs, PARAMS)
    {
       $.each(PARAMS, function(key, value) { PARAMS[key].sourceItem = clickEventArgs.target; });  // NOT RELATED TO THIS ISSUE

       if(PARAMS.length == 1)
       {
          // NOT RELATED TO THIS ISSUE
       }
       else if(PARAMS.length>1)
       {
           showMenu(clickEventArgs, PARAMS);  <<- THIS IS WHERE OUR CASE FOLLOWS
       }
       else
       {
          // NOT RELATED TO THIS ISSUE
       }
    }

3 - Show menu function

    function showMenu(e, PARAMS) 
    {  
        if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) 
        {
            var contextMenu = $find("<%= RadContextMenu1.ClientID %>");

            contextMenu.get_items().clear();
            for(i=0; i < PARAMS.length; i++)
            {
                var childItem = new Telerik.Web.UI.RadMenuItem();
                childItem.set_text(PARAMS[i].title);
                childItem.PARAM=PARAMS[i];
                contextMenu.get_items().add(childItem);
            }

            contextMenu.show(e);
        }
    }

Grid Markup

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
    Skin="Default" AutoGenerateColumns="false" AllowMultiRowSelection="true" OnItemDataBound="RadGrid1_ItemDataBound">
    <ClientSettings EnableRowHoverStyle="true">
        <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="10px" />
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnGridCreated="GridCreated" OnRowClick="RowClicked" OnRowSelected="RowSelectionChanged" OnRowDeselected="RowSelectionChanged"></ClientEvents>
    </ClientSettings>
    <MasterTableView AllowPaging="true">
        <PagerStyle AlwaysVisible="true" />
    </MasterTableView>
</telerik:RadGrid>

Please let me remind that this code "WORKS FINE" The only problem is that the grid doesnt SELECT the row when the cell content is a link.

Without the markup of your grid I can't be certain but I can think of 2 potential solutions.

Firstly, I apologise if you've already tried this but you've not put your grid markup on the question, you need to ensure you have set the selecting set up correctly to allow row selection <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="false" /> .

See: http://www.telerik.com/community/forums/aspnet-ajax/grid/select-a-row-in-radgrid-after-a-linkbutton-in-the-radgrid-is-clicked.aspx

Another potential way of doing this would be to use the RadGrid Client API to select the row, assuming that either the clickEventArgs or PARAMS attributes contain a unique datakeyvalue for you to compare by this could be done using the set_selected function on the item.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM