目前我在.NET MVC中使用Jquery dataTable。当我从下拉列表中选择某些内容并单击搜索按钮时,它会以dataTable格式显示记录。 dataTable中有一列名为detail。当我点击该链接时,它会重定向到另一个页面,该页面显示该特定记录的详细信息。但是当我回去时,它不会显示带有记录的dataTable,也不会显示dataTable。
这是搜索视图:
<div id="search-structure">
</div>
</div>
</div>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
addrSearchButtonClickHandler();
});
function addrSearchButtonClickHandler() {
$(document).off("click", "#Search-by-obsolescence").on("click", "#Search-by-obsolescence", function () {
var build_Type = $("#residenceType").val();
var quality = $("#Quality").val();
var style = $("#firstStyle").val();
if (build_Type == null || build_Type == '') {
displayErrorMessage("Select Building Type value");
return false;
}
if (quality == null || quality == '') {
displayErrorMessage("Select Quality value.");
return false;
}
if (style == null || style == '') {
displayErrorMessage("Select Style value.");
return false;
}
var data = { 'build_Type': build_Type, 'quality': quality, 'style': style };
var Url = "@Url.Content("~")Assessment/AssessmentSearchResultByFunctionalObsolescence";
BlockUI();
// $("#search-structure").removeClass("hide");
$.get(Url, data, function (result) {
UnblockUI();
$("#search-structure").html(result);
// $("#search-structure").addClass("show");
});
});
}
</script>
这是dataTable的另一个观点:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
var imgstr = '<img src="@Url.Content("~")Content/Images/ajax-loader.gif" alt="Please Wait..."/>'
$(".dataTables_processing").html(imgstr);
clearCookie('current_tab');
if ('@Model' == null || '@Model.Count()' == 0 || '@Model.Count()' == 1) {
clearCookie('filterData');
}
var columnIndexes = [7];
makeDataTablesortdisb("dataTable-search-by-Function-Obsolescence", columnIndexes);
var oTable = $('#dataTable-search-by-Function-Obsolescence').dataTable();
$('#dataTable-search-by-Function-Obsolescence').on('draw.dt', function () {
disableSortingSearchOption(oTable, 'dataTables_filter input');
});
$(".dataTables_filter input").after('<img id="grid-search-refresh-button" tabindex="0"class="search-icon" src="@Url.Content("~/Content/images/search-refresh-button-icon.png")" width="28" alt="search" title ="Refresh" style="float: right; position: relative; top: -3px; cursor:pointer;" />');
$("div.dataTables_filter #grid-search-refresh-button").click(function (e) {
$(this).addClass("outline-none");
e.preventDefault();
$("#search-error-text").remove();
$("div.dataTables_filter select option").first().attr('selected', true);
oTable.fnFilter('');
});
DetailClickHandler();
$("#SearchByFunObsolescenceReportPrint").click(function () {
var url = "@Url.Content("~")Reports/ReportViewer/Search_Result_By_Address.aspx";
window.location.href = url;
});
});
function DetailClickHandler() {
$(document).on("click", "#detail", function (e) {
BlockUI();
e.preventDefault();
var parcel_no = $(this).attr("parcel_no");
var assessment_no = $(this).attr("assessment_no");
var url = "@Url.Content("~")Assessment/Assessment?parcel_no=" + parcel_no + "&assesmt_no=" + assessment_no;
window.location.href = url;
});
}
</script>
但我认为对于上述问题只需要改变第一个视图。那是什么解决方案???