如何将 RadToolTip 添加到 JQuery 动态生成的 table 单元格文本
How do I add a RadToolTip to a JQuery dynamically generated table cell text
如何使用 JQuery 将 Radtooltip 添加到出现在动态创建的 table 单元格中的文本中。工具提示弹出窗口应显示来自单元格的数据以及 hyperlink。这是为了 table 显示问题,工具提示应该显示 link 正在使用解决方案页面。
function GenerateProblemResoultionLinks() {
// Open up the landing page for addressing the problem.
function problemLink_Click() {
// Get the problem data from the row.
var $self = $telerik.$(this);
var oProblemData = JSON.parse(
$self.attr("data-Problem")
);
// Add the original message to the problem data.
oProblemData["problemText"] = $self
.text()
.trim();
// Convert the object back to JSON and encode it for transport.
var strProblemDataArgument = encodeURIComponent(
JSON.stringify(oProblemData) );
var strURL =
"problemresolutionpage.aspx?problemData=" +
strProblemDataArgument;
window.open(strURL, "_blank");
}
// Set up the delegated event handler.
$telerik
.$(".PROBLEMDETAILS> tbody")
.on("click", ".problemLink", problemLink_Click);
}
我通过如下修改代码解决了我的问题:
function GenerateProblemResoultionLinks() {
function problemLink_Click() {
// Get the problem data from the row.
var $self = $telerik.$(this);
var oProblemData = JSON.parse(
$self.attr("data-integrationProblem")
);
// Add the original message to the problem data.
oProblemData["problemText"] = $self
.text()
.trim();
if (oProblemData){
// Generate problem soltuion tooltip for each problem type. Needs to stay within the scope of the onclick.
switch(oProblemData.type){
case "ProblemType1":
var IDForSolution1=oProblemData.data["layoutIDT"];
var IDForSolution2 = oProblemData.data["keywordTableIDT"];
var Soltuion1Link="<a href=pageforsoltuion1.aspx?item="+ IDForSolution1 +" target=\"_blank\">UpdateItem</a>";
var Solution2Link="<a href=pageforsolution2.aspx?record="+ IDForSolution2 +" target=\"_blank\">Add New Record</a>";
var toolTipTMsg ="A new record may be added to the record table <br/> OR<br/> item can be updated in the item table."
var radToolTip = $find("<%= RadToolTip1.ClientID %>");
radToolTip.set_targetControl(this);
radToolTip.set_content("<p>" +toolTipTMsg +"</p>-------------------</br>" + Soltuion1Link +"<br/>"+ Soltuion2Link);
radToolTip.show();
break;
default:
break;
}
}
}
// Set up the delegated event handler.
$telerik
.$(".IMPORTEXPORTDETAILS > tbody")
.on("click", ".problemLink", problemLink_Click);
}
我还添加了以下内容:
<telerik:RadToolTip RenderMode="Lightweight" ID="RadToolTip1" runat="server" Title="Problem Solution(s)" IsClientID="true" Callout="false" RelativeTo="Element" Position="MiddleRight" ShowEvent="FromCode" Height="220" Width="300" HideEvent="LeaveToolTip">
</telerik:RadToolTip>
如何使用 JQuery 将 Radtooltip 添加到出现在动态创建的 table 单元格中的文本中。工具提示弹出窗口应显示来自单元格的数据以及 hyperlink。这是为了 table 显示问题,工具提示应该显示 link 正在使用解决方案页面。
function GenerateProblemResoultionLinks() {
// Open up the landing page for addressing the problem.
function problemLink_Click() {
// Get the problem data from the row.
var $self = $telerik.$(this);
var oProblemData = JSON.parse(
$self.attr("data-Problem")
);
// Add the original message to the problem data.
oProblemData["problemText"] = $self
.text()
.trim();
// Convert the object back to JSON and encode it for transport.
var strProblemDataArgument = encodeURIComponent(
JSON.stringify(oProblemData) );
var strURL =
"problemresolutionpage.aspx?problemData=" +
strProblemDataArgument;
window.open(strURL, "_blank");
}
// Set up the delegated event handler.
$telerik
.$(".PROBLEMDETAILS> tbody")
.on("click", ".problemLink", problemLink_Click);
}
我通过如下修改代码解决了我的问题:
function GenerateProblemResoultionLinks() {
function problemLink_Click() {
// Get the problem data from the row.
var $self = $telerik.$(this);
var oProblemData = JSON.parse(
$self.attr("data-integrationProblem")
);
// Add the original message to the problem data.
oProblemData["problemText"] = $self
.text()
.trim();
if (oProblemData){
// Generate problem soltuion tooltip for each problem type. Needs to stay within the scope of the onclick.
switch(oProblemData.type){
case "ProblemType1":
var IDForSolution1=oProblemData.data["layoutIDT"];
var IDForSolution2 = oProblemData.data["keywordTableIDT"];
var Soltuion1Link="<a href=pageforsoltuion1.aspx?item="+ IDForSolution1 +" target=\"_blank\">UpdateItem</a>";
var Solution2Link="<a href=pageforsolution2.aspx?record="+ IDForSolution2 +" target=\"_blank\">Add New Record</a>";
var toolTipTMsg ="A new record may be added to the record table <br/> OR<br/> item can be updated in the item table."
var radToolTip = $find("<%= RadToolTip1.ClientID %>");
radToolTip.set_targetControl(this);
radToolTip.set_content("<p>" +toolTipTMsg +"</p>-------------------</br>" + Soltuion1Link +"<br/>"+ Soltuion2Link);
radToolTip.show();
break;
default:
break;
}
}
}
// Set up the delegated event handler.
$telerik
.$(".IMPORTEXPORTDETAILS > tbody")
.on("click", ".problemLink", problemLink_Click);
}
我还添加了以下内容:
<telerik:RadToolTip RenderMode="Lightweight" ID="RadToolTip1" runat="server" Title="Problem Solution(s)" IsClientID="true" Callout="false" RelativeTo="Element" Position="MiddleRight" ShowEvent="FromCode" Height="220" Width="300" HideEvent="LeaveToolTip">
</telerik:RadToolTip>