How to access

How to access

cutterblcutterbl Posts: 4Questions: 1Answers: 0
edited February 2011 in Plug-ins
I'm trying to write my first plug-in, and running in to some hurdles.

Recently I wrote an example (in testing) that would populate the grid via a server-side request to a ColdFusion Component (CFC), using it's native JSON return format. I overrode the fnServerData option to make this happen, along with a couple of custom functions that I wrote for tailoring the request for the server (outbound) and the client (inbound).

I'd like to encapsulate this functionality in to a plugin, whereby a developer can define a new option in the DataTables config (that option taking it's own config object), and the presence of that option in DataTables initialization would automatically override the fnServerData with the plugin and configuration.

I went back and forth on this for a few hours the other day before banging my head against the desk, so I figured it was time to ask. Any guidance you can give me is appreciated, and I'll be more than happy to blog the entire experience, OS my code, and give you full account for publication here.

Replies

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin
    Hi cutterbl,

    At the moment the only way to modify fnServerData is as an initialisation parameter (or modifying the DataTables source). Unfortunately DataTables does not currently allow defaults to be redefined for the initialisation parameters, which is a flaw that will be addressed in the next major version. However, fnServerData functions which provide the translation are very useful indeed (and rarely the same for two implementations) - I've got a plug-ins page for fnServerData methods here: http://datatables.net/plug-ins/server-data-formats . Currently there is only the OpenSearch method, but I'd be delighted to add your own :-)

    Regards,
    Allan
  • cutterblcutterbl Posts: 4Questions: 1Answers: 0
    @allan,

    Complete write up, with downloadable sample code, at http://blog.cutterscrossing.com/index.cfm/2011/2/7/Using-The-DataTables-JQuery-Plugin. You can view an example at http://examples.cutterscrossing.com/DataTables/. Love to talk ideas sometime.
  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin
    Hi cutterbl,

    Fantastic! Thanks very much for writing that up and posting your source. I've linked your write up from the DataTables news feed.

    If you have any suggestions for how the DataTables API for server-side processing (or any other aspect!), it would be great to hear from you.

    Regards,
    Allan
This discussion has been closed.