rweng / jquery-datatables-rails

jquery-datatables gem for rails
MIT License
564 stars 338 forks source link

Scroller not working on Responsive Installation #88

Closed uhn-nohn closed 10 years ago

uhn-nohn commented 10 years ago

Hello,

I am trying to implement the infinite scrollY. I required the plugin in application.js //= require dataTables/extras/Scroller

Here is my code:

tC = $('#keys')
tC.dataTable
    bJQueryUI: true
    bAutoWidth: false
    bStateSave: false
    sScrollY: "400px"
    sAjaxSource: $('#keys').data('source')
    bServerSide: true
    sDom: "frtiS"
    oScroller:
        loadingIndicator: true
    fnPreDrawCallback: ->
        responsiveHelper = new ResponsiveDatatablesHelper(tC, breakpointDefinition) unless        responsiveHelper
    fnRowCallback: (nRow, aData, iDisplayIndex, iDisplayIndexFull) ->
        responsiveHelper.createExpandIcon nRow
    fnDrawCallback: (oSettings) ->
        responsiveHelper.respond()`

When I add the sScrollY: "400px" the table start to brake, and the responsive side of it is not working at all(no column is hiding, and at resize the column header doesn't resize)

Thank you

ricardodovalle commented 10 years ago

@uhn-nohn Did you solve the issue? Could you try against last version, i did several updates, please see README before.

Thanks

uhn-nohn commented 10 years ago

Hello, thanks for the update. The scroll is working now, but still when you resize the window, the table brakes.

ricardodovalle commented 10 years ago

@uhn-nohn , if it is possible, could you post your code or a create only a small project at github to test this issue, this way it is easier for us to work together. It is very hard to see without correct indentation.

(i never used responsive with scroller) Have you defined breakpointDefinition?

responsiveHelper = undefined
breakpointDefinition =
  tablet: 1024
  phone: 480
uhn-nohn commented 10 years ago

Yes I have them defined, but now when I try to require the //= require dataTables/extras/Scroller, I get couldn't find file 'dataTables/extras/Scroller'. Sorry about the indentation, is fixed now

ricardodovalle commented 10 years ago

@uhn-nohn Please trying using dataTables.scroller.js

//= require dataTables/extras/dataTables.scroller

Now the gem reflect the same at DataTables project

You can see the files here: https://github.com/rweng/jquery-datatables-rails/tree/master/app/assets/javascripts/dataTables/extras

ricardodovalle commented 10 years ago

Please take a look at Readme, dataTables.responsive changed too:

responsiveHelper = undefined
breakpointDefinition =
  tablet: 1024
  phone: 480

tableElement = $("#example")
tableElement.dataTable
  autoWidth: false
  preDrawCallback: ->

    # Initialize the responsive datatables helper once.
    responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition)  unless responsiveHelper
    return

  rowCallback: (nRow) ->
    responsiveHelper.createExpandIcon nRow
    return

  drawCallback: (oSettings) ->
    responsiveHelper.respond()
    return
ricardodovalle commented 10 years ago

This way you must define only once Responsive plugin per page. If you need more, take a look at plugin author Readme to know to do, it is possible. author: https://github.com/Comanche/datatables-responsive

Version: DataTables 1.10.x

ricardodovalle commented 10 years ago

@uhn-nohn Closed by user inactivity. Please reopen if the error persist or to post the answer. Thanks.