server side processing with Rails

server side processing with Rails

techytechy Posts: 3Questions: 0Answers: 0
edited May 2009 in Plug-ins
Hi everyone , I am farily new to databales and wanted to check is there a way I can use databales for a rails application , please advise if there is a tutorial a link some documenation I could use just like how you have for the php

regards,

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    There should be no barrier to using DataTables with a Rails application. The easiest way of doing this integration is just to have your Rails app output the JSON structure that DataTables needs on each draw. See http://datatables.net/1.5-beta/examples/data_sources/server_side.html for an example of server-side processing and what DataTables expects to get back from the server.

    Regards,
    Allan
  • techytechy Posts: 3Questions: 0Answers: 0
    Allan thank you so much for your prompt reply, I was able to create a simple JSON structure in RoR. The second issue I have seems like its currently loading all the records in the HTML, how do I make it to not load all load all records. Please advise
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    You need to limit the number of records that your server-side script returns. DataTables sends a number of GET parameters which you can use to see what it is expected (sorting, filtering, length, start etc). From my link you will be able to see an example PHP script which does the server-side processing. You'll need to port something like that to RoR.

    The other option is just to load all of your rows (which sounds like is what is happening atm) and have DataTables use them on the client-side (just disabled the server-side processing flag). This will work well for smallish tables (upto 500 rows perhaps). After that server-side processing is probably better.

    Allan
  • techytechy Posts: 3Questions: 0Answers: 0
    Hi Allan, seems like you are the owner of datatable.. so let me first congratulate you on making such a useful plugin that is universal in nature.

    I did some homework at my end and found out that in rails we can do the pagination using paginate commands.

    now the question is how do I integrate rails pagination with your plugin. I am pasting below the HTML that gets generated using the rails pagination.

    I am thinking I just need to wrap the and somewhere in the jquery .. please advise

    « Previous 1 2 3 4 5 6 7 8 9 … 64 65 Next »
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi techy,

    It sounds like the code that you found is for pagination done in Rails with output to HTML. I don't think this is really what you want for DataTables integration. What you want to do is output the data in the JSON format that DataTables expects, as done in the link in my first post.

    Regards,
    Allan
  • JoostJoost Posts: 1Questions: 0Answers: 0
    Hi guys,

    First I want to congratulate Allan with the awesome jquery plugin you developed.
    Secondly, I want to thank Chris Warren for the rails_datables plugin he published to simplify the live of a rails developer who want to use the benefits of both worlds.

    I am currently switching from the normal datatable setup to the :ajax_source options, because my dataset becomes to large.

    In the normal setup next to my object columns I also specified hyperlinks
    [code]
    <%= link_to 'Show', patient %>
    <%= link_to 'Edit', edit_patient_path(patient) %>
    <%= link_to 'Destroy', patient, :confirm => 'Are you sure ?', :method => :delete %>

    [/code]

    When I am now migrating to the :ajax_source option, the 'Show' and the 'Edit' link still work,
    But the 'Destroy' link troubles me. The "link_to 'Destroy', patient, :confirm => 'Are you sure ?', :method => :delete" statement generates inline javascript:
    [code]
    'Wis'
    [/code]

    and the jquery datatables plugin doesn't like that.

    Could you give me a hint how to handle this issue ?
    I still want to ask the user for confirmation when, he decides to delete a patient.

    Thanks in advance.
This discussion has been closed.