格式化的数字

formatted_numbers

  • 作者:Allan Jardine
  • 已弃用:此插件已弃用并被其他功能取代。请参阅以下详细说明以获取更多信息。

此插件将去除非数字格式化字符,以便可以自动检测到格式化的数字(例如 1,000,000)并按数值进行排序。请注意,不会自动去除 a-z 字符,否则有可能会将不应识别为数字的列识别为数字列。

DataTables 1.10+ 具有内置的格式化数字类型检测和排序功能。因此,此插件被标记为已弃用,但可能会在使用旧版 DataTables 时有用。

使用

可以使用多种不同方式获取和使用此插件。

浏览器

可以在 DataTables CDN 上找到此插件

JS

然后,插件将自动针对全局 DataTables 实例注册自身。如果你正在使用 Require.js 等 AMD 加载器,也可以使用此文件。

请注意,如果你正在使用多个插件,以单一文件形式将插件合并并将其托管在自己的服务器上,而不是向 DataTables CDN 发出多个请求,这在性能方面是有益的。

NPM

所有插件都可在 NPM 上获得(也可以在 Yarn 或其他 JavaScript 包管理器中使用),作为 datatables.net-plugins 的一部分。要使用此插件,首先安装插件包

1
npm install datatables.net-plugins

ES 模块

然后,如果你正在使用 ES 模块,请导入 datatables.net、任何其他所需的 DataTables 扩展和插件

1
2
import DataTable from 'datatables.net';
import 'datatables.net-plugins/type-detection/formatted-num.mjs';

CommonJS

如果你正在对 Node 使用 CommonJS 加载器(例如旧版 Webpack 或非模块化 Node 代码),请使用以下方法 require 插件

1
2
3
var $ = require('jquery');
var DataTable = require('datatables.net');
require('datatables.net-plugins/type-detection/formatted-num.js');

版本控制

如果你对如何改进此插件有任何想法,或发现任何错误,可以在 GitHub 上获得此插件,欢迎提交请求!

Comments (0)

No comments posted for this page yet. Be the first to contribute!

Post new comment

Contributions in the form of tips, code snippets and suggestions for the above material are very welcome. To post a comment, please use the form below. Text is formatted by Markdown.

To post comments, please sign in to your DataTables account, or register:

Any questions posted here will be deleted without being published.
Please post questions in the Forums. Comments are moderated.