function resetMiTabla(){ $('table').trigger('sortReset'); $('table').trigger('filterReset'); return false; } function inicializarLaTablerow() { // $(function() { //$("table").tablesorter({widthFixed: true, widgets: ['zebra']}); // ********************************** // filter // ********************************** // *** widgetfilter_startsWith toggle button *** $('button.toggle').click(function(){ var c = $('table.tablesorter')[0].config, $t = $(this), // toggle the boolean fsw = !c.widgetOptions.filter_startsWith, fic = !c.widgetOptions.filter_ignoreCase; if ($t.hasClass('fsw')) { c.widgetOptions.filter_startsWith = fsw; $('#start').html(fsw.toString()); } else if ($t.hasClass('fic')) { c.widgetOptions.filter_ignoreCase = fic; $('#case').html(fic.toString()); } else { $t = c.$headers.eq(1).toggleClass('filter-match'); $t.find('span').html( $t.hasClass('filter-match') ? '' : ' No' ); } // update search after option change; add false to trigger to skip search delay $('table.tablesorter').trigger('search', false); return false; }); // ********************************** // Description of ALL pager options // ********************************** var pagerOptions = { // target the pager markup - see the HTML block below container: $(".pager"), // use this url format "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" ajaxUrl: null, // modify the url after all processing has been applied customAjaxUrl: function(table, url) { return url; }, // process ajax so that the data object is returned along with the total number of rows // example: { "data" : [{ "ID": 1, "Name": "Foo", "Last": "Bar" }], "total_rows" : 100 } ajaxProcessing: function(ajax){ if (ajax && ajax.hasOwnProperty('data')) { // return [ "data", "total_rows" ]; return [ ajax.total_rows, ajax.data ]; } }, // output string - default is '{page}/{totalPages}' // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} output: '{startRow} to {endRow} ({totalRows})', // apply disabled classname to the pager arrows when the rows at either extreme is visible - default is true updateArrows: true, // starting page of the pager (zero based index) page: 0, // Number of visible rows - default is 10 size: 10, // Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js) savePages : true, //defines custom storage key storageKey:'tablesorter-pager', // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty // table row set to a height to compensate; default is false fixedHeight: true, // remove rows from the table to speed up the sort of large tables. // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. // Y tambien necesario en false, si se usa filter + pager removeRows: false, // css class names of pager arrows cssNext: '.next', // next page arrow cssPrev: '.prev', // previous page arrow cssFirst: '.first', // go to first page arrow cssLast: '.last', // go to last page arrow cssGoto: '.gotoPage', // select dropdown to allow choosing a page cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) cssDisabled: 'disabled', // Note there is no period "." in front of this class name cssErrorRow: 'tablesorter-errorRow' // ajax error information row }; $("table.tablesorter") // Initialize tablesorter // *********************** .tablesorter({ theme: 'blue', widthFixed: true, // this is the default setting para child rows cssChildRow: "tablesorter-childRow", //widgets: ['zebra', "filter", 'stickyHeaders'], widgets: ['zebra', "filter"], // le quito los stickyHeaders pues hacen overflow-x // headers: { 5: { sorter: false, filter: false } }, widgetOptions : { // filter_anyMatch options was removed in v2.15; it has been replaced by the filter_external option // If there are child rows in the table (rows with class name from "cssChildRow" option) // and this option is true and a match is found anywhere in the child row, then it will make that row // visible; default is false filter_childRows : false, // if true, a filter will be added to the top of each table column; // disabled by using -> headers: { 1: { filter: false } } OR add class="filter-false" // if you set this to false, make sure you perform a search using the second method below filter_columnFilters : true, // extra css class name(s) applied to the table row containing the filters & the inputs within that row // this option can either be a string (class applied to all filters) or an array (class applied to indexed filter) filter_cssFilter : '', // or [] // jQuery selector (or object) pointing to an input to be used to match the contents of any column // please refer to the filter-any-match demo for limitations - new in v2.15 filter_external : '', // class added to filtered rows (rows that are not showing); needed by pager plugin filter_filteredRow : 'filtered', // add custom filter elements to the filter row // see the filter formatter demos for more specifics filter_formatter : null, // add custom filter functions using this option // see the filter widget custom demo for more specifics on how to use this option filter_functions : null, // if true, filters are collapsed initially, but can be revealed by hovering over the grey bar immediately // below the header row. Additionally, tabbing through the document will open the filter row when an input gets focus filter_hideFilters : true, // Set this option to false to make the searches case sensitive filter_ignoreCase : true, // if true, search column content while the user types (with a delay) filter_liveSearch : true, // a header with a select dropdown & this class name will only show available (visible) options within that drop down. filter_onlyAvail : 'filter-onlyAvail', // jQuery selector string of an element used to reset the filters filter_reset : 'button.reset', // Use the $.tablesorter.storage utility to save the most recent filters (default setting is false) filter_saveFilters : true, // Delay in milliseconds before the filter widget starts searching; This option prevents searching for // every character while typing and should make searching large tables faster. // filter_searchDelay : 300, // if true, server-side filtering should be performed because client-side filtering will be disabled, but // the ui and events will still be used. filter_serversideFiltering: false, // Set this option to true to use the filter to find text from the start of the column // So typing in "a" will find "albert" but not "frank", both have a's; default is false filter_startsWith : false, // Filter using parsed content for ALL columns // be careful on using this on date columns as the date is parsed and stored as time in seconds filter_useParsedData : false, // data attribute in the header cell that contains the default filter value filter_defaultAttrib : 'data-value', /* quito los sticky-headers pues me hacen overflow-x // OPCIONES PARA FIJAR LOS HEADER // extra class name added to the sticky header row stickyHeaders : '', // number or jquery selector targeting the position:fixed element stickyHeaders_offset : 0, // added to table ID, if it exists stickyHeaders_cloneId : '-sticky', // trigger "resize" event on headers stickyHeaders_addResizeEvent : true, // if false and a caption exist, it won't be included in the sticky header stickyHeaders_includeCaption : true, // The zIndex of the stickyHeaders, allows the user to adjust this to their needs stickyHeaders_zIndex : 2, // jQuery selector or object to attach sticky header to stickyHeaders_attachTo : null */ } }); /* // External search // buttons set up like this: // */ $('button[data-filter-column]').click(function(){ /*** first method *** data-filter-column="1" data-filter-text="!son" add search value to Discount column (zero based index) input */ var filters = [], $t = $(this), col = $t.data('filter-column'), // zero-based index txt = $t.data('filter-text') || $t.text(); // text to add to filter filters[col] = txt; // using "table.hasFilters" here to make sure we aren't targetting a sticky header $.tablesorter.setFilters( $('table.hasFilters'), filters, true ); // new v2.9 /** old method (prior to tablsorter v2.9 *** var filters = $('table.tablesorter').find('input.tablesorter-filter'); filters.val(''); // clear all filters filters.eq(col).val(txt).trigger('search', false); ******/ /*** second method *** this method bypasses the filter inputs, so the "filter_columnFilters" option can be set to false (no column filters showing) ******/ /* var columns = []; columns[5] = '2?%'; // or define the array this way [ '', '', '', '', '', '2?%' ] $('table').trigger('search', [ columns ]); */ return false; }); // bind to pager events // ********************* $("table").bind('pagerChange pagerComplete pagerInitialized pageMoved', function(e, c){ var msg = '" event triggered, ' + (e.type === 'pagerChange' ? 'going to' : 'now on') + ' page ' + (c.page + 1) + '/' + c.totalPages + ''; $('#display') .append('
  • "' + e.type + msg + '
  • ') .find('li:first').remove(); }) // initialize the pager plugin // **************************** .tablesorterPager(pagerOptions); // Toggle child row content (td), not hiding the row since we are using rowspan // Using delegate because the pager plugin rebuilds the table after each page change // "delegate" works in jQuery 1.4.2+; use "live" back to v1.3; for older jQuery - SOL $('.tablesorter').delegate('.toggle', 'click' ,function(){ // use "nextUntil" to toggle multiple child rows // toggle table cells instead of the row $(this).closest('tr').nextUntil('tr:not(.tablesorter-childRow)').find('td').toggle(); // in v2.5.12, the parent row now has the class tablesorter-hasChildRow // so you can use this code as well // $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle(); return false; }); // hide child rows // $('.tablesorter-childRow td').hide(); //}); }