我的Telerik rad 网格中有用于 Asp.net的自定义列,其中一些显示链接(A href='...')。
链接工作正常。
问题是只有当我单击具有链接(而不是纯文本)的单元格时,网格才选择我单击的单元格的行。
通常,当用户单击常规单元格时,网格会毫无问题地选择行。
这仅在单元格内容是链接时发生。
有什么办法解决这个问题吗?请。
代码:
1 - 链接后面的链接(进入网格单元)
<a href="#" onclick="commandManager(event, otherParameters);">Cotgrave</a>
2 - 被调用的代码。
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 - 显示菜单功能
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);
}
}
网格标记
<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>
请让我提醒一下,此代码“工作正常”唯一的问题是当单元格内容是链接时,网格不会选择行。