mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-20 18:54:15 +01:00
New: dt-api count()
method. This provides a short cut method to determine how many items have been selected by the API. This can be useful to count the number of selected rows, etc.
This commit is contained in:
parent
4f3525786d
commit
d95820dd2a
@ -1 +1 @@
|
||||
854fdf8f2fd10fedf030b93dacc827e097014f10
|
||||
a10e9abed459d124241b2825c70fbf86d373273b
|
||||
|
8
media/js/jquery.dataTables.js
vendored
8
media/js/jquery.dataTables.js
vendored
@ -6795,7 +6795,7 @@
|
||||
_Api.prototype = /** @lends DataTables.Api */{
|
||||
any: function ()
|
||||
{
|
||||
return this.flatten().length !== 0;
|
||||
return this.count() !== 0;
|
||||
},
|
||||
|
||||
|
||||
@ -6805,6 +6805,12 @@
|
||||
context: [], // array of table settings objects
|
||||
|
||||
|
||||
count: function ()
|
||||
{
|
||||
return this.flatten().length;
|
||||
},
|
||||
|
||||
|
||||
each: function ( fn )
|
||||
{
|
||||
for ( var i=0, ien=this.length ; i<ien; i++ ) {
|
||||
|
8
media/js/jquery.dataTables.min.js
vendored
8
media/js/jquery.dataTables.min.js
vendored
@ -93,10 +93,10 @@ u(b,"order"),e=u(b,"filter")||u(b,"search");if(d!==null||e!==null){c.mData={_:a+
|
||||
v(n,null,"order",[n,a,b]);Kb(n)}});z(n,"aoDrawCallback",function(){(n.bSorted||B(n)==="ssp"||w.bDeferRender)&&ya(n)},"sc");hb(n);e=q.children("caption").each(function(){this._captionSide=q.css("caption-side")});j=q.children("thead");0===j.length&&(j=g("<thead/>").appendTo(this));n.nTHead=j[0];j=q.children("tbody");0===j.length&&(j=g("<tbody/>").appendTo(this));n.nTBody=j[0];j=q.children("tfoot");if(0===j.length&&0<e.length&&(""!==n.oScroll.sX||""!==n.oScroll.sY))j=g("<tfoot/>").appendTo(this);0===
|
||||
j.length||0===j.children().length?q.addClass(i.sNoFooter):0<j.length&&(n.nTFoot=j[0],ea(n.aoFooter,n.nTFoot));if(f.aaData)for(e=0;e<f.aaData.length;e++)K(n,f.aaData[e]);else(n.bDeferLoading||"dom"==B(n))&&na(n,g(n.nTBody).children("tr"));n.aiDisplay=n.aiDisplayMaster.slice();n.bInitialised=!0;!1===o&&ha(n)}});b=null;return this};var Ub=[],x=Array.prototype,dc=function(a){var b,c,d=m.settings,e=g.map(d,function(a){return a.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase())return b=
|
||||
g.inArray(a,e),-1!==b?[d[b]]:null;if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?c=g(a):a instanceof g&&(c=a)}else return[];if(c)return c.map(function(){b=g.inArray(this,e);return-1!==b?d[b]:null}).toArray()};s=function(a,b){if(!(this instanceof s))return new s(a,b);var c=[],d=function(a){(a=dc(a))&&c.push.apply(c,a)};if(g.isArray(a))for(var e=0,f=a.length;e<f;e++)d(a[e]);else d(a);this.context=Pa(c);b&&this.push.apply(this,b.toArray?b.toArray():b);this.selector=
|
||||
{rows:null,cols:null,opts:null};s.extend(this,this,Ub)};m.Api=s;s.prototype={any:function(){return 0!==this.flatten().length},concat:x.concat,context:[],each:function(a){for(var b=0,c=this.length;b<c;b++)a.call(this,this[b],b,this);return this},eq:function(a){var b=this.context;return b.length>a?new s(b[a],this[a]):null},filter:function(a){var b=[];if(x.filter)b=x.filter.call(this,a,this);else for(var c=0,d=this.length;c<d;c++)a.call(this,this[c],c,this)&&b.push(this[c]);return new s(this.context,
|
||||
b)},flatten:function(){var a=[];return new s(this.context,a.concat.apply(a,this.toArray()))},join:x.join,indexOf:x.indexOf||function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1},iterator:function(a,b,c,d){var e=[],f,h,g,i,o,l=this.context,m,r,p=this.selector;"string"===typeof a&&(d=c,c=b,b=a,a=!1);h=0;for(g=l.length;h<g;h++){var n=new s(l[h]);if("table"===b)f=c.call(n,l[h],h),f!==k&&e.push(f);else if("columns"===b||"rows"===b)f=c.call(n,l[h],this[h],h),f!==k&&e.push(f);
|
||||
else if("column"===b||"column-rows"===b||"row"===b||"cell"===b){r=this[h];"column-rows"===b&&(m=Ea(l[h],p.opts));i=0;for(o=r.length;i<o;i++)f=r[i],f="cell"===b?c.call(n,l[h],f.row,f.column,h,i):c.call(n,l[h],f,h,i,m),f!==k&&e.push(f)}}return e.length||d?(a=new s(l,a?e.concat.apply([],e):e),b=a.selector,b.rows=p.rows,b.cols=p.cols,b.opts=p.opts,a):this},lastIndexOf:x.lastIndexOf||function(a,b){return this.indexOf.apply(this.toArray.reverse(),arguments)},length:0,map:function(a){var b=[];if(x.map)b=
|
||||
x.map.call(this,a,this);else for(var c=0,d=this.length;c<d;c++)b.push(a.call(this,this[c],c));return new s(this.context,b)},pluck:function(a){return this.map(function(b){return b[a]})},pop:x.pop,push:x.push,reduce:x.reduce||function(a,b){return ib(this,a,b,0,this.length,1)},reduceRight:x.reduceRight||function(a,b){return ib(this,a,b,this.length-1,-1,-1)},reverse:x.reverse,selector:null,shift:x.shift,sort:x.sort,splice:x.splice,toArray:function(){return x.slice.call(this)},to$:function(){return g(this)},
|
||||
{rows:null,cols:null,opts:null};s.extend(this,this,Ub)};m.Api=s;s.prototype={any:function(){return 0!==this.count()},concat:x.concat,context:[],count:function(){return this.flatten().length},each:function(a){for(var b=0,c=this.length;b<c;b++)a.call(this,this[b],b,this);return this},eq:function(a){var b=this.context;return b.length>a?new s(b[a],this[a]):null},filter:function(a){var b=[];if(x.filter)b=x.filter.call(this,a,this);else for(var c=0,d=this.length;c<d;c++)a.call(this,this[c],c,this)&&b.push(this[c]);
|
||||
return new s(this.context,b)},flatten:function(){var a=[];return new s(this.context,a.concat.apply(a,this.toArray()))},join:x.join,indexOf:x.indexOf||function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1},iterator:function(a,b,c,d){var e=[],f,h,g,i,o,l=this.context,m,r,p=this.selector;"string"===typeof a&&(d=c,c=b,b=a,a=!1);h=0;for(g=l.length;h<g;h++){var n=new s(l[h]);if("table"===b)f=c.call(n,l[h],h),f!==k&&e.push(f);else if("columns"===b||"rows"===b)f=c.call(n,l[h],
|
||||
this[h],h),f!==k&&e.push(f);else if("column"===b||"column-rows"===b||"row"===b||"cell"===b){r=this[h];"column-rows"===b&&(m=Ea(l[h],p.opts));i=0;for(o=r.length;i<o;i++)f=r[i],f="cell"===b?c.call(n,l[h],f.row,f.column,h,i):c.call(n,l[h],f,h,i,m),f!==k&&e.push(f)}}return e.length||d?(a=new s(l,a?e.concat.apply([],e):e),b=a.selector,b.rows=p.rows,b.cols=p.cols,b.opts=p.opts,a):this},lastIndexOf:x.lastIndexOf||function(a,b){return this.indexOf.apply(this.toArray.reverse(),arguments)},length:0,map:function(a){var b=
|
||||
[];if(x.map)b=x.map.call(this,a,this);else for(var c=0,d=this.length;c<d;c++)b.push(a.call(this,this[c],c));return new s(this.context,b)},pluck:function(a){return this.map(function(b){return b[a]})},pop:x.pop,push:x.push,reduce:x.reduce||function(a,b){return ib(this,a,b,0,this.length,1)},reduceRight:x.reduceRight||function(a,b){return ib(this,a,b,this.length-1,-1,-1)},reverse:x.reverse,selector:null,shift:x.shift,sort:x.sort,splice:x.splice,toArray:function(){return x.slice.call(this)},to$:function(){return g(this)},
|
||||
toJQuery:function(){return g(this)},unique:function(){return new s(this.context,Pa(this))},unshift:x.unshift};s.extend=function(a,b,c){if(c.length&&b&&(b instanceof s||b.__dt_wrapper)){var d,e,f,h=function(a,b,c){return function(){var d=b.apply(a,arguments);s.extend(d,d,c.methodExt);return d}};d=0;for(e=c.length;d<e;d++)f=c[d],b[f.name]="function"===typeof f.val?h(a,f.val,f):g.isPlainObject(f.val)?{}:f.val,b[f.name].__dt_wrapper=!0,s.extend(a,b[f.name],f.propExt)}};s.register=p=function(a,b){if(g.isArray(a))for(var c=
|
||||
0,d=a.length;c<d;c++)s.register(a[c],b);else for(var e=a.split("."),f=Ub,h,j,c=0,d=e.length;c<d;c++){h=(j=-1!==e[c].indexOf("()"))?e[c].replace("()",""):e[c];var i;a:{i=0;for(var k=f.length;i<k;i++)if(f[i].name===h){i=f[i];break a}i=null}i||(i={name:h,val:{},methodExt:[],propExt:[]},f.push(i));c===d-1?i.val=b:f=j?i.methodExt:i.propExt}};s.registerPlural=u=function(a,b,c){s.register(a,c);s.register(b,function(){var a=c.apply(this,arguments);return a===this?this:a instanceof s?a.length?g.isArray(a[0])?
|
||||
new s(a.context,a[0]):a[0]:k:a})};p("tables()",function(a){var b;if(a){b=s;var c=this.context;if("number"===typeof a)a=[c[a]];else var d=g.map(c,function(a){return a.nTable}),a=g(d).filter(a).map(function(){var a=g.inArray(this,d);return c[a]}).toArray();b=new b(a)}else b=this;return b});p("table()",function(a){var a=this.tables(a),b=a.context;return b.length?new s(b[0]):a});u("tables().nodes()","table().node()",function(){return this.iterator("table",function(a){return a.nTable},1)});u("tables().body()",
|
||||
|
Loading…
x
Reference in New Issue
Block a user