gpt4 book ai didi

javascript - 我的代码有什么问题吗?学习 Bootstrap

转载 作者:行者123 更新时间:2023-11-28 05:23:45 25 4
gpt4 key购买 nike

我是 Bootstrap 新手,仍在学习它。我目前正在做我自己的这个项目。我设法在不使用参数的情况下查看数据表。在我的项目中,我在第一个数据表中单击后有两个数据表,参数应传递到第二个数据表(空)(示例 ID) 并且它将加载数据。如果我的 Controller 中没有参数并使用 a.BookTransactionHdrID == 100 中的特定值,它将加载。但这不是我想要发生的事情。大家有什么想法吗?

enter image description here

JS 代码

function fnGetStudentBook(getId) {

if (getId != 0 || getId != undefined || getId != "") {
dtStudBook = $('#dtBook').DataTable({
responsive: true,
processing: true,
info: true,
retrieve: true,
destroy: true,
search: true,
stateSave: true,
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: {
"url": "/LS/GetStudentBook",
"data": function (d) {
d.BookTransactionDtlID = getId;
}
},
columns:
[
{ data: "BookId", title: "", visible: false, searchable: false },
//{ data: "Barcode", title: "Barcode", searchable: false },
{ data: "Author", title: "Author" }
// { data: "Title", title: "Title", sClass: "alignRight" },
// { data: "DatePublish", title: "Date Publish", sClass: "alignRight" },
// { data: "PlacePublish", title: "Place Publish" },
// { data: "NameOfPublisher", title: "Name Of Publisher"},
// { data: "ISBN", title: "ISBN"},
// { data: "BookTransactionDtlID", title: "", visible: false }
]
});
}
else {
//do nothing..
}
}

Controller

public JsonResult GetStudentBook(int getId)
{
// int getId = Convert.ToInt32(Request.QueryString["getId"]);
var Data = new List<object>();
Data = (from a in db.BookTransactionDtls
join b in db.Books on a.BookID equals b.BookID
where a.BookTransactionTypeID == 3 && a.BookTransactionHdrID == getId
select new
{
BookId = a.BookID,
//Barcode = b.Barcode,
Author = b.Author
//Title = b.Title,
//DatePublish = b.DatePublished,
//PlacePublish = b.PlacePublished,
//NameOfPublisher = b.NameOfPublisher,
//ISBN = b.ISBN,
//BookTransactionDtlID = a.BookTransactionDtlID
}).OrderBy(a => a.BookId).ToList<object>();
return gf.DataTableAjaxHandlerClientSide(Data);
}

HTML

<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-lg-6">
<i class="fa fa-list fa-fw"></i>Book
</div>
</div>
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="dataTable_wrapper">
<div class="col-lg-6">
<table class="table table-striped table-bordered table-hover table-responsive nowrap"
role="grid" style="width: 10%;" id="dtBook">
</table>
</div>
</div>
</div>
</div>
</div>

onclick传递参数的代码

var getId = 0;
var dtStudBook = "";
var dtBorrowerName = $('#dtBorrowerName').DataTable({
responsive: true,
processing: true,
info: true,
search: true,
stateSave: true,
order: [[1, "desc"]],
lengthMenu: [[5, 10, 20, -1], [5, 10, 20, "All"]],
ajax: { "url": "/LS/GetBorrower" },
columns:
[
{ data: "BorrowerID", title: "", visible: false, searchable: false },
{ data: "IDNo", title: "ID Number" },
{ data: "Name", title: "Complete Name", sClass: "alignRight", width: " 100px" },
{ data: "BookTransactionHdrID", title: "BookTransactionHdrID", visible: false, searchable: false }
]
});



$('#dtBorrowerName tbody').on('click', 'tr', function (e) {
getId = dtBorrowerName.row(this).data().BookTransactionHdrID;
alert(getId);
fnGetStudentBook(getId)
});

最佳答案

你可以在你的ajax中像jqgrid那样做这样的事情。

 ajax: {
"url": "/LS/GetStudentBook?getId=" + getId
},

如果您熟悉[“Session”]。在您的代码中,Request.QueryString["getId"] 与 Session 类似。

希望有帮助。干杯。

关于javascript - 我的代码有什么问题吗?学习 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40328953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com