- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个数据表,我想通过调用服务并在其中添加新行来重绘它。
为此,我使用了以下代码:
$(function() {
var dataFromService = [{
"ScheduleId": 1324,
"Started": "26 Oct 2018 06:12:17",
"EstimatedCompletionTime": "26 Oct 2018 10:12:49",
"EstTimeToComplete": 240,
"NoDelScheduled": 3,
"NoPartsScheduled": 11,
"NoSheetsScheduled": 534,
"NoPartsPrepared": 5,
"NoSheetsPicked": 312,
"NoBlocksUsed": 64,
"NoPalletsUsed": 3,
"SheetsPerMin": 1.3,
"SecondsPerSheet": 46.15
}];
$('#btnRedraw').on('click', function() {
var datatable = $('#testDataTable001').DataTable();
datatable.clear();
datatable.rows.add(dataFromService);
datatable.draw();
//console.log(datatable);
});
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<div class="dataTables_scroll">
<div class="dataTables_scrollHead" style="overflow: hidden; position: relative; border: 0px; width: 100%;">
<div class="dataTables_scrollHeadInner" style="box-sizing: content-box; width: 2606px; padding-right: 0px;">
<table class="table table-hover dataTable" role="grid" style="margin-left: 0px; width: 2606px;">
<thead>
<tr role="row">
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="ScheduleId: activate to sort column ascending">ScheduleId</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="Started: activate to sort column ascending">Started</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 168px;" aria-label="EstimatedCompletionTime: activate to sort column ascending">EstimatedCompletionTime</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="EstTimeToComplete: activate to sort column ascending">EstTimeToComplete</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoDelScheduled: activate to sort column ascending">NoDelScheduled</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoPartsScheduled: activate to sort column ascending">NoPartsScheduled</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoSheetsScheduled: activate to sort column ascending">NoSheetsScheduled</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoPartsPrepared: activate to sort column ascending">NoPartsPrepared</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoSheetsPicked: activate to sort column ascending">NoSheetsPicked</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoBlocksUsed: activate to sort column ascending">NoBlocksUsed</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="NoPalletsUsed: activate to sort column ascending">NoPalletsUsed</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="SheetsPerMin: activate to sort column ascending">SheetsPerMin</th>
<th class="sorting" tabindex="0" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px;" aria-label="SecondsPerSheet: activate to sort column ascending">SecondsPerSheet</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="dataTables_scrollBody" style="position: relative; overflow: auto; max-height: 26vh; width: 100%;">
<table id="testDataTable001" class="table table-hover dataTable" role="grid" style="width: 100%;">
<thead>
<tr role="row" style="height: 0px;">
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="ScheduleId: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">ScheduleId</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="Started: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">Started</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 168px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="EstimatedCompletionTime: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">EstimatedCompletionTime</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="EstTimeToComplete: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">EstTimeToComplete</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoDelScheduled: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoDelScheduled</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoPartsScheduled: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoPartsScheduled</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoSheetsScheduled: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoSheetsScheduled</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoPartsPrepared: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoPartsPrepared</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoSheetsPicked: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoSheetsPicked</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoBlocksUsed: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoBlocksUsed</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="NoPalletsUsed: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">NoPalletsUsed</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="SheetsPerMin: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">SheetsPerMin</div>
</th>
<th class="sorting" aria-controls="testDataTable001" rowspan="1" colspan="1" style="width: 162px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" aria-label="SecondsPerSheet: activate to sort column ascending">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;">SecondsPerSheet</div>
</th>
</tr>
</thead>
<tfoot>
<tr style="height: 0px;">
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="ScheduleId" data-index="0" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="Started" data-index="1" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 190px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="EstimatedCompletionTime" data-index="2" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="EstTimeToComplete" data-index="3" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoDelScheduled" data-index="4" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoPartsScheduled" data-index="5" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoSheetsScheduled" data-index="6" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoPartsPrepared" data-index="7" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoSheetsPicked" data-index="8" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoBlocksUsed" data-index="9" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="NoPalletsUsed" data-index="10" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="SheetsPerMin" data-index="11" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
<th rowspan="1" colspan="1" style="padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; width: 184px;">
<div class="dataTables_sizing" style="height: 0px; overflow: hidden;"><input name="SecondsPerSheet" data-index="12" class="form-control js-footer-search" type="text" placeholder="Search"></div>
</th>
</tr>
</tfoot>
<tbody>
<tr role="row" class="odd">
<td>1324</td>
<td>26 Oct 2018 06:12:17</td>
<td>26 Oct 2018 10:12:49</td>
<td>240</td>
<td>3</td>
<td>11</td>
<td>534</td>
<td>5</td>
<td>312</td>
<td>64</td>
<td>3</td>
<td>1.3</td>
<td>46.15</td>
</tr>
</tbody>
</table>
</div>
<div class="dataTables_scrollFoot" style="overflow: hidden; border: 0px; width: 100%;">
<div class="dataTables_scrollFootInner" style="width: 2606px; padding-right: 0px;">
<table class="table table-hover dataTable" role="grid" style="margin-left: 0px; width: 2606px;">
<tfoot>
<tr>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="ScheduleId" data-index="0" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="Started" data-index="1" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 190px;"><input name="EstimatedCompletionTime" data-index="2" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="EstTimeToComplete" data-index="3" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoDelScheduled" data-index="4" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoPartsScheduled" data-index="5" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoSheetsScheduled" data-index="6" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoPartsPrepared" data-index="7" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoSheetsPicked" data-index="8" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoBlocksUsed" data-index="9" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="NoPalletsUsed" data-index="10" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="SheetsPerMin" data-index="11" class="form-control js-footer-search" type="text" placeholder="Search"></th>
<th rowspan="1" colspan="1" style="width: 184px;"><input name="SecondsPerSheet" data-index="12" class="form-control js-footer-search" type="text" placeholder="Search"></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<button type="button" id="btnRedraw">Re-draw</button>
最佳答案
$(function() {
var datatable = $('#testDataTable001').DataTable({
columns:[
{data: 'ScheduleId'},
{data: "Started"},
{data: "EstimatedCompletionTime"},
{data: "EstTimeToComplete"},
{data: "NoDelScheduled"},
{data: "NoPartsScheduled"},
{data: "NoSheetsScheduled"},
{data: "NoPartsPrepared"},
{data: "NoSheetsPicked"},
{data: "NoBlocksUsed"},
{data: "NoPalletsUsed"},
{data: "SheetsPerMin"},
{data: "SecondsPerSheet"}]
});
var dataFromService = [{
"ScheduleId": 1324,
"Started": "26 Oct 2018 06:12:17",
"EstimatedCompletionTime": "26 Oct 2018 10:12:49",
"EstTimeToComplete": 240,
"NoDelScheduled": 3,
"NoPartsScheduled": 11,
"NoSheetsScheduled": 534,
"NoPartsPrepared": 5,
"NoSheetsPicked": 312,
"NoBlocksUsed": 64,
"NoPalletsUsed": 3,
"SheetsPerMin": 1.3,
"SecondsPerSheet": 46.15
}];
$('#btnRedraw').on('click', function() {
// datatable.clear();
datatable.rows.add(dataFromService);
datatable.draw();
//console.log(datatable);
});
})
<link href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<table id="testDataTable001" class="display" style="width:100%">
<thead>
<tr>
<th>ScheduleId</th>
<th>Started</th>
<th>EstimatedCompletionTime</th>
<th>EstTimeToComplete</th>
<th>NoDelScheduled</th>
<th>NoPartsScheduled</th>
<th>NoSheetsScheduled</th>
<th>NoPartsPrepared</th>
<th>NoSheetsPicked</th>
<th>NoBlocksUsed</th>
<th>NoPalletsUsed</th>
<th>SheetsPerMin</th>
<th>SecondsPerSheet</th>
</tr>
</thead>
<tbody>
<tr role="row" class="odd">
<td>1321</td>
<td>26 Oct 2018 06:12:17</td>
<td>26 Oct 2018 10:12:49</td>
<td>240</td>
<td>3</td>
<td>11</td>
<td>534</td>
<td>5</td>
<td>312</td>
<td>64</td>
<td>3</td>
<td>1.3</td>
<td>46.15</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
</table>
<button type="button" id="btnRedraw">Re-draw</button>
保持 DataTable
实例在需要时全局重用该对象。单击按钮时不需要 datatable.clear();
。
关于javascript - 添加具有未知请求参数的行时 jQuery DataTable 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53753824/
我创建了一个用户可以添加测试的字段。这一切运行顺利我只希望当用户点击(添加另一个测试)然后上一个(添加另一个测试)删除并且这个显示在新字段中。 所有运行良好的唯一问题是点击(添加另一个字段)之前添加另
String[] option = {"Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebant
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在努力将 jQuery 滚动功能添加到 nav-tab (Bootstrap 3)。我希望用户能够选择他们想要的选项卡,并在选项卡内容中有一个可以平滑滚动到 anchor 的链接。这是我的代码,可
我正在尝试在用户登录后再添加 2 个 ui 选项卡。首先,我尝试做一个之后。 $('#slideshow').tabs('remove', '4'); $("#slideshow ul li:last
我有一个包含选择元素的表单,我想通过选择添加和删除其中一些元素。这是html代码(这里也有jsfiddle http://jsfiddle.net/txhajy2w/):
正在写这个: view.backgroundColor = UIColor.white.withAlphaComponent(0.9) 等同于: view.backgroundColor = UICo
好的,如果其中有任何信息,我想将这些列添加到一起。所以说我有 账户 1 2 3 . 有 4 个帐户空间,但只有 3 个帐户。我如何创建 java 脚本来添加它。 最佳答案 Live Example H
我想知道是否有一种有效的预制算法来确定一组数字的和/差是否可以等于不同的数字。示例: 5、8、10、2,使用 + 或 - 等于 9。5 - 8 = -3 + 10 = 7 + 2 = 9 如果有一个预
我似乎有一个卡住的 git repo。它卡在所有基本的添加、提交命令上,git push 返回所有内容为最新的。 从其他帖子我已经完成了 git gc 和 git fsck/ 我认为基本的调试步骤是
我的 Oracle SQL 查询如下- Q1- select hca.account_number, hca.attribute3, SUM(rcl.extended_amou
我正在阅读 http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingG
我正在尝试添加一个“加载更多”按钮并限制下面的结果,这样投资组合页面中就不会同时加载 1000 个内容,如下所示:http://typesetdesign.com/portfolio/ 我对 PHP
我遇到这个问题,我添加了 8 个文本框,它工作正常,但是当我添加更多文本框(如 16 个文本框)时,它不会添加最后一个文本框。有人遇到过这个问题吗?提前致谢。 Live Link: JAVASCRIP
add/remove clone first row default not delete 添加/删除克隆第一行默认不删除&并获取正确的SrNo(例如:添加3行并在看到问题后删除SrNo.2)
我编码this ,但删除按钮不起作用。我在控制台中没有任何错误.. var counter = 0; var dataList = document.getElementById('materi
我有一个类似数组的对象: [1:数组[10]、2:数组[2]、3:数组[2]、4:数组[2]、5:数组[3]、6:数组[1]] 我正在尝试删除前两个元素,执行一些操作,然后将它们再次插入到同一位置。
使用的 Delphi 版本:2007 你好, 我有一个 Tecord 数组 TInfo = Record Name : String; Price : Integer; end; var Info
我使用了基本的 gridster 代码,然后我声明了通过按钮添加和删除小部件的函数它工作正常但是当我将调整大小功能添加到上面的代码中时,它都不起作用(我的意思是调整大小,添加和删除小部件) 我的js代
title 323 323 323 title 323 323 323 title 323 323 323 JS $(document).keydown(function(e){
我是一名优秀的程序员,十分优秀!