我想单击主页上的一个项目,传递一个ID,然后基于该ID以模态加载数据
我在点击发生的cshtml页面中有以下代码
<div class="modal" id="myModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Modal body text goes here.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
$.ajax({
type: "Post",
url: "/Home/GetImageFromLogId?LogId=" + this.specialId,
success: function (data) {
$("#modal-content").html(data);
$("#myModal").modal("show");
},
error: function () {
alert('error!');
}
})
然后我将其放在家庭控制器中
[HttpPost] public ActionResult GetImageFromLogId(long LogId) { var requestedImageData = processIt.LoadGraphImageData(LogId); return PartialView(requestedImageData); }
processIt.LoadGraphImageData只需返回一个带有日期,图像位置和一些ID的对象
我想在模态中显示此信息,但是我显然缺少了一些东西
我是MVC的新手,所以努力找出缺少的部分
答案 0 :(得分:0)
我需要添加cshtml文件,然后添加此文件
function go(){
var excel = $JExcel.new("Calibri light 10 #333333");
excel.set( {sheet:0,value:"This is Sheet 1" } );
excel.addSheet("Sheet 2");
var evenRow=excel.addStyle ( { // Style for even ROWS
border: "none,none,none,thin #333333"});
var oddRow=excel.addStyle ( { // Style for odd ROWS
fill: "#ECECEC" , // Background color, plain #RRGGBB, there is a helper $JExcel.rgbToHex(r,g,b)
border: "none,none,none,thin #333333"});
for (var i=1;i<50;i++) excel.set({row:i,style: i%2==0 ? evenRow: oddRow }); // Set style for the first 50 rows
excel.set({row:3,value: 30 }); // We want ROW 3 to be EXTRA TALL
var headers=["Header 0","Header 1","Header 2","Header 3","Header 4"]; // This array holds the HEADERS text
var formatHeader=excel.addStyle ( { // Format for headers
border: "none,none,none,thin #333333", // Border for header
font: "Calibri 12 #0000AA B"}); // Font for headers
for (var i=0;i<headers.length;i++){ // Loop all the haders
excel.set(0,i,0,headers[i],formatHeader); // Set CELL with header text, using header format
excel.set(0,i,undefined,"auto"); // Set COLUMN width to auto (according to the standard this is only valid for numeric columns)
}
// Now let's write some data
var initDate = new Date(2000, 0, 1);
var endDate = new Date(2016, 0, 1);
var dateStyle = excel.addStyle ( {
align: "R",
format: "yyyy.mm.dd hh:mm:ss",
font: "#00AA00"});
for (var i=1;i<50;i++){
excel.set(0,0,i,"This is line "+i);
var d=randomDate(initDate,endDate);
excel.set(0,1,i,d.toLocaleString());
excel.set(0,2,i,$JExcel.toExcelLocalTime(d));
excel.set(0,3,i,$JExcel.toExcelLocalTime(d),dateStyle);
excel.set(0,4,i,"Some other text");
}
excel.generate("SampleData.xlsx");//the file to append to file uploader .
}