我有包含下一个数据的 DataTable 对象:
Id Value
1 val1
3 val2
2 val3
Run Code Online (Sandbox Code Playgroud)
我接下来选择一行:
table.Select("Id=1");
Run Code Online (Sandbox Code Playgroud)
这个查询给了我行
1 val1
Run Code Online (Sandbox Code Playgroud)
接下来我想选择所选行旁边的行,即行
3 val2
Run Code Online (Sandbox Code Playgroud)
我能以某种方式做到这一点吗?是否可以?也许表中存在类似于行位置的东西,我可以用它来通过增加这个值来选择下一行?
我正在使用带有响应式插件的数据表,
https://cdn.datatables.net/responsive/2.1.1/css/responsive.dataTables.css
https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.js
Run Code Online (Sandbox Code Playgroud)
这是我的屏幕结果:
移动视图顶部:
移动视图底部:
我的JS代码:
dataTable = $('#agency_data').DataTable({
"processing":true,
"serverSide":true,
"order":[],
responsive: true,
"language": {
"infoFiltered": ""
},
"ajax":{
url:base_url+"/agency-listing",
type:"POST"
},
"columnDefs":[
{
"targets":[0, 3], //first and last not sortable
"orderable":false,
},
],
});
Run Code Online (Sandbox Code Playgroud)
我表格的HTML:
<table id="agency_data" class="table table-bordered table-striped">
<thead>
<tr class="info">
<th width="10%">ID</th>
<th width="15%">Agency Code</th>
<th width="65%">Agency Name</th>
<th width="15%">Action</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
JSFIDDLE: 这里
题:
1)在移动视图上,如何获得完整显示的Long组织名称?像BR?
2)如何摆脱底部的水平滚动,使用户无需在移动视图上滚动?
我在我的Web应用程序中使用Datatable.以下是使用ajax获取数据的简单代码.
<script>
$(document).ready(function() {
$('#mytable').DataTable();
} );
</script>
<body>
<h2>AJAX SELECT</h2><hr>
<div align="center">
Select Team :
<select name="select" id ='teamSelect'>
<option value="">Select Value</option>
<option value="op2">Company 1</option>
</select>
</div>
<div id='tableContainer' align="center"></div>
<script>
$(function() {
$("#teamSelect").bind("change", function() {
$.ajax({
type: "GET",
url: "getData.php",
"dataSrc": "tableData",
success: function(html) {
$("#tableContainer").html(html);
}
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
和Getdata.php代码
<table id="mytable" class="display" cellspacing="0" width="50%">
<thead>
<tr>
<th>First name</th>
<th>Last Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration Specialist</td> …Run Code Online (Sandbox Code Playgroud) 我正在使用每个类名称的自定义过滤。我的页面上也有两个不同的dataTables,但是似乎要添加的过滤器适用于两个dataTables。我想指定它实际应用于哪一个。
$.fn.dataTableExt.afnFiltering.push(function (oSettings, aData, iDataIndex) {
var myRowClasses = oSettings.aoData[iDataIndex].nTr.className.split(" ");
if($("#subplayers").is(":checked")) {
return myRowClasses.indexOf('insub') > -1;
} else {
return myRowClasses.indexOf('allplayers') > -1;
}
});
Run Code Online (Sandbox Code Playgroud)
此过滤器适用于两个表(具有表1 tabledata和具有id的表2 tabledata2)。如何修改此代码以使其仅在表1上起作用?
表格代码:
var table = $('#tabledata').DataTable({
'fnCreatedRow': function (nRow, aData, iDataIndex) {
$(nRow).attr('id', 'col' + iDataIndex+'_filter');
if (initatedTable){
$(nRow).addClass("insub");
$(nRow).addClass("allplayers");
}
}
});
var table2 = $('#tabledata2').DataTable({
'fnCreatedRow': function (nRow, aData, iDataIndex) {
$(nRow).attr('id', 'col' + iDataIndex+'_filter');
}
});
Run Code Online (Sandbox Code Playgroud) 我有桌子
<table id="account-table" class="table display nowrap" cellspacing="0" width="100%">
<thead>
<tr class="text-left">
<th>ID</th>
<th>Type</th>
<th>Name</th>
<th>Email Address</th>
<th>Action</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
这是我的搜索输入框
<input type="text" class="form-control mb20" id="search" placeholder="Search">
Run Code Online (Sandbox Code Playgroud)
我已经尝试过此设置
**include**
<script src="https://cdn.datatables.net/plug-ins/1.10.10/features/searchHighlight/dataTables.searchHighlight.min.js" type="text/javascript"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://bartaz.github.io/sandbox.js/jquery.highlight.js"></script>
**settings**
$('#account-table').DataTable({
data: data,
deferRender: true,
paging: true,
searching: true,
bLengthChange : false,
Filter: false,
Info:false,
searchHighlight:true,
iDisplayLength: 10,
});
**trigger the draw while typing**
$('#search').keyup(function(){
$('#account-table').search($(this).val()).draw();
});
Run Code Online (Sandbox Code Playgroud)
我不确定为什么在开始输入搜索输入框时我的搜索功能不起作用。
控制台中有0错误。
我该如何调试?
I would like to had (multiple) data-attributes to the generated rows of my JQuery DataTable so that I can store data in it.
What I want to achieve is to make DataTables generate something like this:
<tr data-foo="bar">
<td></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
Is it possible? How to do it? Thanks.
我正在努力使数据表的一列中的文本不被换行。

我想避免在第一列中换行(因为这是使行大小变大的唯一部分),但应将选项保留在标题中(以避免滚动)。
我尝试过调整第一列的宽度,但是无论我使用什么大小,文本都会自动换行。
DT::datatable(chartfilter,
rownames = FALSE,
options=list(iDisplayLength=7,
bPaginate=FALSE,
bLengthChange=FALSE,
bFilter=FALSE,
bInfo=FALSE,
rowid = FALSE,
autoWidth = FALSE,
ordering = FALSE,
scrollX = TRUE,
columnDefs = list(list(width='500px', targets = list(1)))
Run Code Online (Sandbox Code Playgroud)
我还找到了一种解决方案,可以关闭整个表中的文字换行功能-但我不希望列标签使用这种方式。将其添加到tableoutput前面的UI中:
tags$style(HTML("#charttable {white-space: nowrap; }")),
Run Code Online (Sandbox Code Playgroud)
这可能吗,还是我只需要在第一列中接受换行文本?感谢您可以获得的任何帮助,如果需要更多信息,请告诉我。
我正在动态地将行和列添加到数据表中.这些行添加到我能看到的范围,但是一旦我运行代码,就不会出现任何内容.一旦foreach循环完成,它就像是在刷新表格吗?菜鸟问题.抱歉.
summaryTable.Columns.Add("StationName", typeof(string));
summaryTable.Columns.Add("DepartmentCode", typeof(string));
var row = summaryTable.NewRow();
foreach (var item in issuesByClass)
{
row.SetField("StationName", item.StationName);
row.SetField("DepartmentCode", item.DepartmentCode);
foreach (var itemClass in item.Lookup)
{
if (!itemClassLookup.ContainsKey(itemClass.Key)) continue;
var itemClassValue = itemClassLookup[itemClass.Key];
// Ensure column hasn't been added before
if (!summaryTable.Columns.Contains(itemClassValue))
{
summaryTable.Columns.Add(itemClassValue, typeof(decimal));
}
row.SetField(itemClassValue, itemClass.Sum());
}
if (!summaryTable.Columns.Contains("GrandTotal"))
{
summaryTable.Columns.Add("GrandTotal", typeof(decimal));
}
row.SetField("GrandTotal", item.GrandTotal);
}
return summaryTable;
Run Code Online (Sandbox Code Playgroud)
小窗口形成应用示例:
public Form1()
{
this.InitializeComponent();
this.Test();
}
public void Test()
{
var dt = new DataTable();
var subs = new[] { …Run Code Online (Sandbox Code Playgroud) 我是.net核心api的新手。我想在数据表上使用AsEnumerable,并且需要添加
System.Data.DataSetExtensions为对我的项目的引用。我的项目下没有看到参考部分。
似乎我需要编辑csproj文件。这就是我的csproj文件现在的外观。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.7.0" />
<PackageReference Include="Z.Dapper.Plus" Version="1.3.26" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
如何添加System.Data.DataSetExtensions到现有项目中?谢谢大家
我有一个数据框,如下所示:(还有很多要评估的列和行)
ID COL1 COL2 COL3 COL4
1 x x
2 x x
3
4 x x
5 x
Run Code Online (Sandbox Code Playgroud)
我想获得X在第1-4列(不为每个ID计数之前的外观)中的外观总和,对于上面给出的示例,答案是:
COL1 COL2 COL3 COL4
2 1 1 0
Run Code Online (Sandbox Code Playgroud)
我详细说明:我对每个ID的第1列中的所有错误进行计数,然后进入第二列,发现尽管该列中有两个标记,但其中一个属于ID 1,这已经在第1列中说明了。因此,第2列仅出现1个新的外观,第3列只有一个错误,第4列没有新的错误,因为该列中的两个外观均已被考虑。
datatable ×10
jquery ×5
c# ×3
datatables ×3
r ×2
.net ×1
ajax ×1
asp.net-core ×1
css ×1
datarow ×1
dplyr ×1
dynamic ×1
foreach ×1
html-table ×1
javascript ×1
php ×1
shiny ×1