I want to change default two buttons pager to full number. Maybe this can be done with $parameters['datatable_options'], but where should I add this code?
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | datatables-869724-7.patch | 12.54 KB | duellj |
| #3 | datatables_enable_features2.patch | 14.09 KB | anschauung |
| #2 | datatables_enable_features.patch | 5.09 KB | anschauung |
Comments
Comment #1
xenolon commented(Bump)
I would also like to know how to set the various options DataTables. For instance, how does one turn off pagination, or set multiple-column sorting, or save states, etc.
Outside of Drupal, one would just set these options in the initialization script, like:
$(document).ready(function() {
$('#example').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"bAutoWidth": false } );
} );
This doesn't appear to work if I place the initialization code in the template, and I don't see any options in the module, or views.
Comment #2
anschauung commentedThis patch adds some of the dataTables initialization options to the style configuration menu. This hasn't been extensively tested, so any feedback would be helpful.
I added the features that I use most often, but "duellj made it pretty easy to add others with trivial modifications to the code, so let me know if you need a patch that adds another option before these features get added to the official versions.
Comment #3
anschauung commentedA better patch is attached here. Use this one instead.
Comment #4
xenolon commentedI get:
Hunk #1 FAILED at 178.
Hunk #2 FAILED at 241.
Comment #5
anschauung commentedAt first glance, it looks like a problem with line endings or version mismatches. Are you running a Windows server and/or an older version of the Module? If the latter, try upgrading to the newest version and running the patch again.
Comment #6
duellj commentedanschauung:
Thanks for the patch; I appreciate the work you've put into it. Most of the new configuration options look great, though there's still some work that needs to be done for the hidden/expandable options:
-Selecting a field as hidden/expandable shows all subsequent fields in the expanded box.
-Expanded box doesn't expand fully across all rows.
-I would like the expanded fields to be themable, hopefully using a theme() call.
-Class logic in datatables-view.tpl.php should be in template_preprocess_datatables_view().
If you want to split out the hidden/expandable code from the rest of the configuration options, I can commit that while we work on the former.
Comment #7
duellj commentedTry out this patch and see if it works for you. I've made the expandable row themable, as well as moved all logic into template_preprocess_datatables_view() and datatables.js. If it's working correctly for you, I'll commit it.
Comment #8
anschauung commented@duellj:
Works great so far, thanks! (And, a special thanks for fixing up the overall sloppiness in my expandable columns :)
I did end up adding some simple logic to Drupal.theme.prototype.datatablesExpandableRow so that views columns that have empty labels don't show up as "undefined" in the expanded columns. You might consider that to be a theme preference though.
Comment #9
duellj commentedThanks for the review, anschauung. I've committed the patch to both 6.x-1.x-dev and 7.x-1.x-dev branches.
The "undefined" label was actually a bug, thanks for finding it!
Note to self, collapsed fieldsets cause errors in views-3.x in D7: #893862: Collapsed fieldsets in plugin style options_form cause problems. Fix when issue is fixed.
Comment #10
anschauung commentedI've come across a few other minor nits as I was integrating this into a more complex site. These are probably too small to bother with a patch, so I'll just describe them here:
1) template_preprocess_datatables_view doesn't account for hidden-only (i.e. not expandable) columns. Something like the code below should do the trick:
2) dataTables 1.5.2 is referenced in hook_requirements, but 1.5.x doesn't work with Drupal.theme.prototype.datatablesExpandableRow since that version responds differently to rowData = datatable.fnGetData(row).
This could be fixed easily by upgrading to dataTables 1.6 or dataTables 1.7. Some people might not want to upgrade since newer versions of bAutoWidth miscalculates the width of large datatables in some edge cases, but referencing the newer version is probably the right way to go for most people.
3) The headers and labels on Drupal.theme.prototype.datatablesExpandableRow are off by one. I didn't notice this at first since I was using my own theme functions. Changing settings.aoColumnHeaders[index] to settings.aoColumnHeaders[index-1] is a quick and sloppy fix, or you could re-do the indexes. I believe this is related to the extra column that was added in the earlier Drupal.behaviors function
Thanks again for all your work on this!
Comment #11
duellj commentedReopening this until I get the items in #10 fixed.
1) Good catch, I'll add in the switch statement.
2) Good point, I should update the documentation to download dataTables 1.6. dataTables 1.7 depends on jquery 1.4, which even jquery_update isn't using yet (#685060: Get ready for 1.4).
3) This was fixed in CVS, if you do a checkout of 6.x-1.x-dev is it still happening?
Thanks again for all your help!
Note about bug from #9: actually it's a critical core bug #561858: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework
Comment #12
duellj commentedFixed in CVS for both 6.x and 7.x branches