我正在使用 jquery 数据表插件使用 ajax 填充 web 表中的数据。但我想通过调用存在于 js 文件中的方法填充数据而不进行 ajax 调用。有什么办法吗?
分享我的代码。
ajax : $.fn.dataTable.pipelineAdv({
url : oMapUrls.loadDefaultMap,
pages : !bLivePaginate ? -1 : Global.pageSize,
method : "POST",
contentType : "application/json",
data : function() {
var requestData = {
serverSide : false
};
if (bTimeFiltered) {
requestData.withInTime = iFilterByTime;
}
if (sFilteredVehicleIds) {
requestData.vehicleIds = sFilteredVehicleIds;
}
return requestData;
},
redraw : function() {
return (getPageName() === "map");
},
callback : function(oJSON, request) {
aLiveFleetData = oJSON.serverResponse.result;
if (mapRefreshTimer) { …Run Code Online (Sandbox Code Playgroud) 在数据表中添加任何行后,单击编辑或删除按钮不起作用。我已经用 ajax 做到了这一点。在成功函数中,我破坏了数据表。然后加载所有数据并启动dataTable。我的代码如下。
HTML代码:
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<button class="btn btn-success" title="Add Items" id="addCalzone"><i class="halflings-icon white plus"></i> Add Item</button><br/><br/>
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>Price</th>
<th>
<div class="text-center">
Action
</div>
</th>
</tr>
</thead>
<tbody class="dataTable-tbody">
<?php foreach($row as $key => $r): ?>
<tr class="tableRow" data-id="<?= htmlentities(stripcslashes($r['id']), ENT_QUOTES, 'UTF-8'); ?>">
<td></td>
<td><?= htmlentities(stripcslashes($r['name']), ENT_QUOTES, 'UTF-8'); ?></td>
<td> $ <?= htmlentities(stripcslashes($r['price']), ENT_QUOTES, 'UTF-8'); ?></td>
<td>
<div class="text-center">
<button class="btn btn-info editCalzone" title="Edit"><i class="halflings-icon white edit"></i> Edit</button>
<button class="btn btn-danger dltCalzone" title="Delete"><i …Run Code Online (Sandbox Code Playgroud) 我需要将以下 Json 字符串转换为 DataTable。
{
"pnr":"1234567890",
"train_num":"12311",
"train_name":"HWH DLIKLK MAI",
"doj":"23-12-2013",
"from_station":
{
"code":"DLI",
"name":"Delhi"
},
"to_station":
{
"code":"KLK",
"name":"Kalka"
}
}
Run Code Online (Sandbox Code Playgroud)
在数据表中我需要显示
train_num
train_name
doj
from_station(name only)
to_station(name only)
Run Code Online (Sandbox Code Playgroud)
到目前为止我所拥有的是,
public class Train
{
public string train_num { get; set; }
public string train_name { get; set; }
public string doj { get; set; }
public from_station from_station { get; set; }
public to_station to_station { get; set; }
}
public class from_station
{
public string code { get; …Run Code Online (Sandbox Code Playgroud) 我需要向数据表中添加一列。此列将具有递增序列号,如 1、2、3、4 等...
我找到了这个例子,但这不适用于服务器端处理,我想要搜索排序工作(如果可能),这也不在这里。
https://datatables.net/examples/api/counter_columns.html
笔记:
1) Datatable 使用服务器端处理。
2)排序和搜索应该在那个计数器列上工作。(如果可能的话)
3)如果我可以使用js在客户端完全实现它会很好。我不想为此在服务器端编写任何代码(如果可能的话)。
4) 分页应该连续更新计数器编号意味着如果上一页的最后一个计数器编号为 15,那么下一页应该从计数器 16 开始。
顺便说一下,我还检查了这一点:
但是这个问题的公认答案违反了我的第四个要求。
任何帮助,将不胜感激。
谢谢,
帕斯沃拉
我得到了一个从 Excel 文件中得到的数据表。现在,我想对按块、移植和品种分组的数据表的 Quantity1 和 Quantity2 列求和。有可能这样做吗?
这是我从 Excel 文件中得到的数据表:
这是我需要的结果:
如何调整 HTMLTamplateFormatter 中数据的数字格式。我希望数字格式为“(0,0)”。以下是错误尝试的示例代码:
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, TableColumn, HTMLTemplateFormatter, NumberFormatter
from bokeh.io import show
dict1 = {'x':[0]*6,'y':[500,1000,-1000,1000,-5000,500],'z':[0,0,1,1,1,2]}
source = ColumnDataSource(data=dict1)
template="""
<b><div style="background:<%=
(function colorfromint(){
if(z == 1){
return("NavajoWhite")}
else{if(z == 2){
return("Orange")}
else{return("")}
}}()) %>;
font-style:'(0,0)'"> ### this part needs fixed
<%= value %></div></b>
"""
formater = HTMLTemplateFormatter(template=template)
columns = [
TableColumn(field="x", title="x"),
TableColumn(field="y", title="y",formatter=formater)
]
data_table = DataTable(source=source, columns=columns, width=800)
show(data_table)
Run Code Online (Sandbox Code Playgroud) 我已将我的解决方案升级到最新版本的 ASPNETZERO V4.x。我有两个模板 MVC5 和 .NET Core 版本。我进行了升级,因为我非常喜欢使用 DataTables 插件,并且已经在我的 ASPNETZERO 解决方案的现有版本中的所有代码中实现了。看来 ASPNETZERO 已经实现了 DataTables 的“自定义”版本。现在我升级前的工作数据表正在崩溃。我已将 Metronic 源代码中作为示例提供的可编辑数据表代码复制到我的 ASPNETZERO 解决方案中,并且运行良好。现在在 V4.X 升级之后它已经破坏了这个代码。当我在下载的解决方案中查看租户、角色和用户等页面的 DataTables 使用脚本时,我看到应用于 Datatables 初始化的选项在 Datatables 文档中不存在。例如,在 Datatables.net 文档中找不到初始化属性“listAction”。
var dataTable = _$usersTable.DataTable({
listAction: {
ajaxFunction: _userService.getUsers,
inputFilter: function () {
return {
filter: $('#UsersTableFilter').val(),
permission: $("#PermissionSelectionCombo").val(),
role: $("#RoleSelectionCombo").val()
};
}
},
Run Code Online (Sandbox Code Playgroud)
以上让我相信这是 ASPNETZERO 团队的 Datatables 的“自定义”版本。我没有看到有关如何使用此“自定义”版本的任何文档,并且来自 DataTables.net 站点的文档与我在提供的解决方案中看到的代码不匹配。有没有其他人遇到过这样的问题?是否有关于此“自定义”数据表实现的文档?
@Alper 当我说硬编码时,我的意思是这样的:
<table class="table table-bordered table-striped table-hover" id="tblRel">
<thead>
<tr>
<td>Version</td>
<td>Publish Date MST</td>
<td>Publish Date <b>GMT</b></td>
<td>Release notes</td>
</tr> …Run Code Online (Sandbox Code Playgroud) 我创建了一个表(使用数据表)并在表中执行了一些操作。在表格中,我有一个按钮可以执行“删除”功能,也使用数据表进行分页。例如,我在第 5 页,我想在单击时删除一行删除它刷新页面并返回到第 1 页。如何在操作删除后使其保留在第 5 页?下面是我的表和控制器功能
viewStatistics.blade:
<table class="table table-hover demo-table-search table-responsive-block alt-table" id="tableWithSearch">
<thead>
<tr>
<th class="text-center" style="width:80px;">ID</th>
<th class="text-center">Date</th>
<th class="text-center">Question <br> Asked</th>
<th class="text-center">Low <br> Confidence</th>
<th class="text-center">No <br> Answer</th>
<th class="text-center">Missing <br> Intent</th>
<th class="text-center">Webhook <br> Fail</th>
<th class="text-center">Status</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
@foreach($data as $sessionID => $value)
<tr>
<td class="text-center">{{$value['identifier']}}</td>
<td class="text-center">{{date("d M", strtotime($value['dateAccess']))}}</td>
<td class="text-center">{{$value['total']}}</td> <!-- question asked -->
<td class="text-center">{{$value['low confidence']}}</td> <!-- low confidence -->
<td class="text-center">{{$value['no answer']}}</td> <!-- no answer …Run Code Online (Sandbox Code Playgroud)我有一个 Primefaces 数据表,其中一列有三个输出文本和一个带有工具提示的命令按钮。该按钮显示为输出标签
这是用于出口标签。这是用于 text.org.primefaces.component.commandbutton.CommandButton@3f60d3f9
如何不包含/打印带有工具提示的命令按钮以将数据表导出到 excel?
我无法将命令按钮移动到业务案例的新列。
我有一张桌子,里面有 2 个<tr>。我需要把这个包2 <tr>,做v-for的包装。但是v-for在<tbody>打破数据表。
<table class="table table-striped" id="data_table">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody v-for="item in items">
<tr>
<td>{{ item.A }}</td>
<td>{{ item.A }}</td>
<td>{{ item.A }}</td>
<td>{{ item.A }}</td>
<td>{{ item.A }}</td>
<td>{{ item.A }}</td>
</tr>
<tr>
<td>{{ item.T }}</td>
<td>{{ item.T }}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
<table class="table table-striped" id="data_table">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<div v-for="item …Run Code Online (Sandbox Code Playgroud) datatable ×10
c# ×3
jquery ×3
datatables ×2
php ×2
asp.net ×1
bokeh ×1
export ×1
html ×1
indexing ×1
javascript ×1
jsf ×1
json ×1
json.net ×1
laravel ×1
linq ×1
pagination ×1
primefaces ×1
server-side ×1
sql ×1
vue.js ×1
wrapper ×1