-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pager + Group (tablesorter) no working properly #1035
Comments
Hi @fcferreira29! The pager + group widget combo does correctly refresh across different pages. I set up this demo. The "Student" column is set up to only group the first 7 letters, or the word "Student", so it doesn't appear to change the group header at all. The other columns show the appropriate group header while paging through the rows. So, it sounds like the issue you're reporting is about the date. If I had to guess, I would say that either the date parser isn't set up for the date format. For example, dateFormat : "ddmmyyyy" or that the "group-date-day" class isn't being used. If you shared the code being used, it would make it easier to find the issue. |
we are using the pager like this: .tablesorterPager({
// target the pager markup - see the HTML block below
container: $('.pager' + id),
// target the pager page select dropdown - choose a page
cssGoto: '.pagenum' + id ,
// dropdown that sets the "size" option
cssPageSize: '.pagesize' + id,
// 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.
removeRows: true,
// Number of visible rows - default is 10
size: 100,
// Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js)
savePages: false,
// output string - default is '{page}/{totalPages}';
// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'
}); and we set the pager to the eaven if i change to another field, with text, the result is the same. |
The pager code isn't where the issue lies. Please share the tablesorter code, or better yet, modify the demo I shared to show me the problem. |
i changed the github can you tell me what i am doing wrong? |
Ok, the date "05-Jan" isn't recognized as a valid date by the built-in parsers; they all expect to see a year. So you'll need to use a custom parser (demo) $.tablesorter.addParser({
// use a unique id
id: 'ddMM',
is: function () {
return false;
},
format: function (s, table, cell, cellIndex) {
var months = table.config.widgetOptions.group_months,
modified = s.replace(/(\d+)-(\w+)/, function (str, d, m) {
var indx = $.inArray(m, months) + 1;
// replace month text with one-based index; swap month & date
return indx > 0 ? indx + '/' + d + '/2015' : str;
}),
date = s ? new Date(modified) : s;
return date instanceof Date && isFinite(date) ? date.getTime() : s;
},
type: 'numeric'
}); Make sure the headers have the parser set: <th class="group-date-day sorter-ddMM">Date 1</th>
<th class="group-date-day sorter-ddMM">Date 2</th>
<th class="group-date-day sorter-ddMM">Date 3</th> The "80" in the top right column is interpreted as "Jan 01 1980" so that's why the group title is showing "Jan 1". |
Note: Using this javascript acts differently in each browser: new Date('05-Jan')
So that's why there is code to swap & replace values so the code is parsing a valid date. |
I found what the problem is, if this is set to true removeRows: true, the pager does not work with grouping the parser you gave me works very well, thanks |
Ok, thanks for that update... I'll look into updating the group widget. |
I am having na issue with the use of both the pager and the group,
here is the problem,
on the first page the Month and day is correct but on the second page, the Months and days are the same as the 1st page, so the group is not refreshing from 1 page to the next one,
The text was updated successfully, but these errors were encountered: