tablesorter - Custom select filter function based on a selector instead of column number? -
from docs read filter_functions used follows:
filter_functions: { // add these options select dropdown (regex example) 2 : { "a - d" : function(e, n, f, i) { return /^[a-d]/.test(e); }, "e - h" : function(e, n, f, i) { return /^[e-h]/.test(e); }, "i - l" : function(e, n, f, i) { return /^[i-l]/.test(e); }, "m - p" : function(e, n, f, i) { return /^[m-p]/.test(e); }, "q - t" : function(e, n, f, i) { return /^[q-t]/.test(e); }, "u - x" : function(e, n, f, i) { return /^[u-x]/.test(e); }, "y - z" : function(e, n, f, i) { return /^[y-z]/.test(e); } } } this makes custom filter function 3rd column. wonder if it's possible specify selector, e.g. .columnwithcoolfiltefunction instead of column number?
the reason have multiple tables of columns contain similar data - , should filtered in same way - column number might 1 in 1 table , 5 in another.
i understand 1 solution initiate every table own options, initiate every table same way (less code, yay!).
possible?
right isn't possible, did have same idea! can track this issue when ever gets implemented.
but in mean time, can set filter object before initializing table:
var alphabetical = { "a - d" : function(e, n, f, i) { return /^[a-d]/.test(e); }, "e - h" : function(e, n, f, i) { return /^[e-h]/.test(e); }, "i - l" : function(e, n, f, i) { return /^[i-l]/.test(e); }, "m - p" : function(e, n, f, i) { return /^[m-p]/.test(e); }, "q - t" : function(e, n, f, i) { return /^[q-t]/.test(e); }, "u - x" : function(e, n, f, i) { return /^[u-x]/.test(e); }, "y - z" : function(e, n, f, i) { return /^[y-z]/.test(e); } }; $("table").tablesorter({ widgetoptions : { filter_functions: { 0 : alphabetical 2 : alphabetical } }, // other options }); and yes, have initialize each table separately until =(
Comments
Post a Comment