Guide to writing custom extensions? (DataTable + Backbone integration)

Guide to writing custom extensions? (DataTable + Backbone integration)

pimlottcpimlottc Posts: 4Questions: 1Answers: 0

I'm looking for some pointers in writing a custom extension. I want to take the code I have been using to integrate DataTables and Backbone (using Backbone views to render individual cells) and package it up as its own extension for simplicity and re-use. I've taken a look at some of the existing extensions but there's a good deal of variation and it's not clear what's really necessary. Any pointers?

For some background in what I'm doing, I described my approach in a pull request a bit ago: https://github.com/DataTables/DataTables/pull/425

Aside from requiring a small patch in DataTables itself, there's a decent bit of boilerplate code needed to manage creating the views and keep the data model consistent between Backbone and DataTables, which you can see in a live demo here: http://live.datatables.net/futuwife/22/edit

Ideally I'd like to take that last example (where each row is represented by a single model) and have it work with "out of the box" with just the model and view definitions and a configuration something like:

    columns: [
      { title: "Name", attribute: "name" },
      { title: "Position", attribute: "position" },
      { title: "Location", attribute: "office" },
      { title: "Extension", attribute: "extn" },
      { title: "Start Date", attribute: "start_date" },
      { title: "Salary (USD)", attribute: "salary", view: "SalaryColumnView" },
    }

So the extension would need to be able to do at least two things:
1) hook into DataTable initialization to create the invalidationManager automatically
2) hook into DataTable column options to add options that would generate Backbone-specific data/render functions

There would still be the issue of needing some modification of DataTables to allow direct rendering into the element but that's another issue; this at least would hide away all the view creation/caching and model invalidation boilerplate.

This discussion has been closed.