【发布时间】:2016-09-24 13:15:45
【问题描述】:
嘿嘿, 我有一个数据表,其中包含来自我的数据库的数据。每行都有一个详细信息按钮。我希望单击按钮以打开包含单击行详细信息的模式。 我试图在页面加载时为每一行创建模态实例,但它减慢了网站的速度。 有没有办法根据行 ID 填充模式?
这是我的桌子
<table id="tblMessagesDetail" class="table table table-hover table-striped table-condensed export-table" style="width: 100%;">
<thead>
<tr>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.Id)*@
@ViewRes.SharedStrings.SmsID
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.Account.Project.Customer.Name)*@
@ViewRes.SharedStrings.CustomerName
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.Account.Project.Name)*@
@ViewRes.SharedStrings.ProjectName
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.Account.Login)*@
@ViewRes.SharedStrings.Account
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].MSISDN)
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.SmsStatus.Value)*@
@ViewRes.SharedStrings.smsStatus
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.EventReason)
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SendDate)*@
@ViewRes.SharedStrings.SendDate
</th>
<th>
@*@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.SentDate)*@
@ViewRes.SharedStrings.SentDate
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].SmsMT.Ticket)
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].ExtId)
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].SmsMTContent.NotificationLevel)
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].SmsMTContent.OADC)
</th>
<th>
@Html.DisplayNameFor(model => model.SmsList[0].SmsMTContent.Message)
</th>
<th>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.SmsList)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.Project.Customer.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.Project.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.NMGLogin)
</td>
<td>
@Html.DisplayFor(modelItem => item.MSISDN)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.SmsStatus.Value)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.EventReason)
</td>
<td>
@Html.DisplayFor(modelItem => item.SendDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.SentDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Ticket)
</td>
<td>
@Html.DisplayFor(modelItem => item.ExtId)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.NotificationLevel)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.OADC)
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.Message)
</td>
<!-- Button trigger modal -->
<td>
@*@using (Html.BeginForm("FillDetailModal", "Statistics", FormMethod.Post))
{*@
<button id="btnDetails" type="submit" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal-@item.SmsMTId">
<i class="glyphicon glyphicon-th-list"></i> @ViewRes.SharedStrings.btnDetails
</button>
</td>
</tr>
}
</tbody>
这是我的模态
<div class="modal fade" draggable="true" id="myModal-@item.SmsMTId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div id="modalDialog" draggable="true" class="modal-dialog" style="padding-bottom:0px">
<div class="modal-content">
<div class="modal-header" style="background-color: #428bca; color: white; ">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
Message Detail ID: '@item.SmsMTId' - Ticket #@item.SmsMT.Ticket - Project @item.SmsMT.Account.Project.Name
</h4>
</div>
<div class="modal-body" style="padding: 0px;">
<table style="width:100%;" class="table table table-hover table-striped table-condensed export-table" border="0">
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.SmsID</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Id)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.CustomerName</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.Project.Customer.Name)
</td>
</tr>
<tr>
<td align="left">
<label> @ViewRes.SharedStrings.ProjectName</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.Project.Name)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.Account</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Account.NMGLogin)
</td>
</tr>
<tr>
<td align="left">
<label> @Html.DisplayNameFor(model => model.SmsList[0].MSISDN)</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.MSISDN)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.smsStatus</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.SmsStatus.Value)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.EventReason</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.EventReason)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.SendDate</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SendDate)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.SentDate</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.SentDate)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.TicketId</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMT.Ticket)
</td>
</tr>
<tr>
<td align="left">
<label>@ViewRes.SharedStrings.ExternalID</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.ExtId)
</td>
</tr>
<tr>
<td align="left">
<label style="width:160px;">@ViewRes.SharedStrings.NotificationLevel</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.NotificationLevel)
</td>
</tr>
<tr>
<td align="left">
<label> @Html.DisplayNameFor(model => model.SmsList[0].SmsMTContent.OADC)</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.OADC)
</td>
</tr>
<tr>
<td align="left">
<label>@Html.DisplayNameFor(model => model.SmsList[0].SmsMTContent.Message)</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.Message)
</td>
</tr>
<tr>
<td align="left">
<label> @ViewRes.SharedStrings.binaryMessage</label>
</td>
<td>
@Html.DisplayFor(modelItem => item.SmsMTContent.Binary)
</td>
</tr>
</table>
</div>
<div class="modal-footer" style="margin: 0px; padding: 9px 30px 10px;">
<button type="button" class="btn btn-default" data-dismiss="modal">
@ViewRes.SharedStrings.btnClose
</button>
</div>
</div>
</div>
</div>
如何传递行的值,然后在数据库上进行链接以提取适当的数据?
感谢我能得到的任何帮助
【问题讨论】:
标签: html datatable bootstrap-modal