我有一个 jquery 数据表,其中日期列格式为 2018 年 2 月 16 日,但是当它被排序时,它没有被正确排序。
我已经使用了这里提到的所有与日期相关的列类型
但似乎没有任何效果。我该如何解决?
这是代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="panel-body btnsize">
<table class="table table-striped table-bordered dttable" id="JsDataTable" style="border-radius: 17px 17px 0 0; border-style: solid; border-color: #fcfdfa;" width:100%;>
<thead>
<tr>
<th style="width: 1px !important;" class="tblth">
Sr
</th>
<th class="tblth" style="width:13% !important;">
Date <i class="fa fa-fw fa-sort"></i>
</th>
</tr>
</thead>
<tbody class="dtbody tblth" style="color: #004D6B;">
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
var table = $("#JsDataTable").DataTable({
scrollY: '50vh',
scrollCollapse: true,
"aaData": response,
"pagingType": "full_numbers",
"dom": '<"top"i>rt<"bottom"flp><"clear">',
"sDom": 'Rfrtlip', …Run Code Online (Sandbox Code Playgroud) 我有一个 ag-grid 的角度实现,其中有一些自定义单元格渲染器。它们呈现从按钮到切换状态到应用程序其他部分的链接等内容。
我最近遇到了一个问题,即仅使用键盘的用户无法通过选项卡进入这些单元格渲染器的内容来“单击”元素。我尝试过放置一个tabindex="0"和/或一个href="#"放在这些元素上,以便它们出现在页面的选项卡顺序中,但它们获得焦点的唯一方法是通过单击鼠标。
似乎 ag-grid 覆盖了键盘的默认行为,也许是用箭头键添加 addtl 功能等。但它似乎与这些自定义渲染器配合得不好......
下面是这些渲染器之一的简化版本的示例。
@Component({
selector: 'fave-renderer',
template: `
<i class="icon fave"
tabindex="0"
(click)="toggleFave()"></i>
`,
styles: [``]
})
export class FaveRendererComponent implements ICellRendererAngularComp {
public params: any;
agInit(params: any): void {
this.params = params;
}
constructor(private resultsService: ResultsService) {}
refresh(): boolean {return false;}
toggleFave() {/*implementation not important... */}
}Run Code Online (Sandbox Code Playgroud)
我试图将一些日期字符串解析为日期值,但是,使用下面的代码,我遇到了异常:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("Q'Q'uuuu - MMM");
String d = "3Q2016 - Aug";
System.out.println(LocalDate.parse(d, formatter));
Run Code Online (Sandbox Code Playgroud)
下面是例外
java.time.format.DateTimeParseException: Text '3Q2016 - Aug' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {MonthOfYear=8, QuarterOfYear=3, Year=2016},ISO of type java.time.format.Parsed
Run Code Online (Sandbox Code Playgroud)
查看异常,我看到了正确的数据,但是由于某种原因无法对其进行解析。
我看到的其他类似主题建议使用LocalDate或LocalDateTime,但均无效。