[英]loading a table of data into bootstrap modal, after clicking a bar on google charts
The main issue I am having is I can't understand how I could attach the data-toggle and data-target attributes needed for bootstrap3 to dispatch the output from my struts action to the modal. 我遇到的主要问题是我不明白如何附加bootstrap3所需的data-toggle和data-target属性,以将输出从我的struts操作分配到模式。
I have a stacked bar chart created with google charts. 我有一个用Google图表创建的堆积条形图。 I was trying to load a table of the relevent data into a twitter bootstrap modal when a bar is clicked using the addlistener function. 我试图使用addlistener函数单击某个栏时将相关事件数据表加载到twitter引导程序模式中。 I am using struts2 to bring back the relevent data. 我正在使用struts2带回相关事件数据。
google.visualization.events.addListener(chart, 'select', SelectionHandler);
function SelectionHandler() {
var selection = <s:property value="key"/>chart.getSelection();
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (item.row != null && item.column != null) {
var Type = <s:property value="key"/>Data
.getValue(item.row,
(item.column + 1));
}
}
location.href = "test.action?Type="
+ Type + "&LoB=<s:property value="key"/>";
}
the data being passed is all correct its mainly I dont know how to get the location.href actions output to be shown in the popup 传递的数据都是正确的,主要是我不知道如何获取location.href动作输出以显示在弹出窗口中
hope someone can help, I can give any other details if need. 希望有人可以提供帮助,如有需要,我可以提供其他详细信息。
thanks, Jim 谢谢,吉姆
I got this working thanks to @goodyzain's advice; 感谢@goodyzain的建议,我得以完成这项工作; JS JS
var chart = new google.visualization.BarChart(
document.getElementById('<s:property value="key"/>'));
google.visualization.events.addListener(chart, 'select', SelectionHandler);
chart.draw(Data,
<s:property value="key" escapeJavaScript="true"/>Options);
function <s:property value="key"/>SelectionHandler() {
var selectedItem = chart.getSelection()[0];
if (selectedItem) {
var value = Data.getValue(selectedItem.row, (selectedItem.column+1));
var key = "<s:property value='key'/>";
}
//value variable contains Type value
$.ajax({
url: "applicationFreqTesting",
type: "POST",
data: {LoB: key, Type: value},
dataType: "HTML",
error: function(XMLHttpRequest, textStatus, errorThrown){
alert('Error ' + textStatus);
alert(errorThrown);
alert(XMLHttpRequest.responseText);
},
success: function(data){
$("#ApplicationListBody").html(data);
$("#ApplicationList").modal();
}
});
}
}
Struts: 支柱:
<action name="applicationFreqTesting" class="com.bt.nfmi.action.Action" method="applicationFreqTesting">
<result name="success">/pages/includes/popUpJourneyReportTesting.jsp</result>
</action>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.