FineAdmin.Web/Content/lib/datatables/examples/plug-ins/api.html

(开头部分) 26KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
	<title>DataTables example - API plug-in methods</title>
	<link rel="stylesheet" type="text/css" href="../../media/css/jquery.dataTables.css">
	<link rel="stylesheet" type="text/css" href="../resources/syntax/shCore.css">
	<link rel="stylesheet" type="text/css" href="../resources/demo.css">
	<style type="text/css" class="init">
	
	</style>
	<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js">
	</script>
	<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js">
	</script>
	<script type="text/javascript" language="javascript" src="../resources/syntax/shCore.js">
	</script>
	<script type="text/javascript" language="javascript" src="../resources/demo.js">
	</script>
	<script type="text/javascript" language="javascript" class="init">
	

$.fn.dataTable.Api.register( 'column().data().sum()', function () {
	return this.reduce( function (a, b) {
		var x = parseFloat( a ) || 0;
		var y = parseFloat( b ) || 0;
		return x + y;
	} );
} );

/* Init the table and fire off a call to get the hidden nodes. */
$(document).ready(function() {
	var table = $('#example').DataTable();
	
	$('<button>Click to sum age in all rows</button>')
		.prependTo( '#demo' )
		.on( 'click', function () {
			alert( 'Column sum is: '+ table.column( 3 ).data().sum() );
		} );

	$('<button>Click to sum age of visible rows</button>')
		.prependTo( '#demo' )
		.on( 'click', function () {
			alert( 'Column sum is: '+ table.column( 3, {page:'current'} ).data().sum() );
		} );
} );


	</script>
</head>
<body class="dt-example">
	<div class="container">
		<section>
			<h1>DataTables example <span>API plug-in methods</span></h1>
			<div class="info">
				<p>The DataTables API is designed to be fully extensible, with custom functions being very easy to add using the <code>$.fn.dataTable.Api.register</code> function.
				This function takes two arguments; the first being the name of the method to be added and its chaining hierarchy, and the second the function itself.</p>
				<p>This example shows how a <code>sum()</code> method can easily be added to the Api so you can get the sum of a column in a single line:
后面还有 884 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。