summaryrefslogtreecommitdiff
path: root/_posts/2011-09-01-does-datatables-need-better-integration.html
diff options
context:
space:
mode:
authorJosé Mota <josemota.net@gmail.com>2012-04-06 19:40:37 +0100
committerJosé Mota <josemota.net@gmail.com>2012-04-06 19:40:37 +0100
commit3204575bfcd1f12db5945c8959073d40915cfdfe (patch)
tree5b35a0896f91043c931482b5ecb99dc2aa154310 /_posts/2011-09-01-does-datatables-need-better-integration.html
parent6644e3213758ac5f8ea4f388d4dcf4105e7d4530 (diff)
Import all posts.
Diffstat (limited to '_posts/2011-09-01-does-datatables-need-better-integration.html')
-rw-r--r--_posts/2011-09-01-does-datatables-need-better-integration.html35
1 files changed, 35 insertions, 0 deletions
diff --git a/_posts/2011-09-01-does-datatables-need-better-integration.html b/_posts/2011-09-01-does-datatables-need-better-integration.html
new file mode 100644
index 0000000..6eed784
--- /dev/null
+++ b/_posts/2011-09-01-does-datatables-need-better-integration.html
@@ -0,0 +1,35 @@
+---
+layout: post
+title: Does Datatables need better integration?
+tags:
+- datatables
+- Development
+- functional
+- javascript
+status: publish
+type: post
+published: true
+meta:
+ _edit_last: '1'
+---
+Over these last two months, I've been working with <a href="http://datatables.net" target="_blank">Datatables</a>, an amazing easy-to-setup steroid machine for HTML tables. For the kind of work I'm doing right now, it suits my needs just perfectly.
+
+A couple of weeks ago I needed to build a plugin for DT: <em>MultipleFilters</em>, something that would allow me to filter data by a range. Each column would have a pair of fields and I would have to mix them into the bowl of parameters to send to the server . It looked fun, so I started doing it, hoping to achieve a beautiful Javascript prototype object that would <a title="Enable features by adding a letter in the sequence of features." href="http://datatables.net/development/features" target="_blank">do magic when plugged in by a single letter</a>. As I was finishing building it, I realized some issues had to be fixed.
+
+<!--more-->
+
+<strong>Disclaimer</strong>: The plugin does not approach local processing, only server-side.
+<h3>Push data to the server without using fnServerData</h3>
+With minimum coupling in mind, I wanted to find a way that allowed to push data to the server without using the <code>fnServerData</code> option in the initializer. That's not what the end user wants, he wants to just download the plugin, place it in and there, it does range filtering.
+
+My suggestion here would be an array of functions (perhaps called <code>afnbeforeSend</code>) that allowed any plugin builder to be able to inject parameters to be sent. That way, when my plugin is initialized, I can push my function that injects such parameters and I don't pollute the initializers.
+<h3>Integrate with other plugins, such as ColVis or ColReorder</h3>
+Datatables' features that have controls, such as MF, require a DOM object to be returned in the fnInit function. As of now, I am generating the feature with just a button. The actual controls are being appended to the table's footer, with no regard to the column order or state of visualization.
+
+At some point in time, I faced a lot of trouble as I watched multiple controls get spawned across the table, as well as the controls not being switched along with the column being reordered nor being hidden / shown when you check a column with <code>ColVis</code>. Wouldn't it be great if both <code>ColVis</code> and <code>ColReorder</code> had some sort of array of callbacks we could populate? When <code>ColVis</code> toggled a column, I could access it and toggle my filter controls accordingly. When <code>ColReorder</code> dragged a column around, I could know which one and to where it moved. All of this without requiring additional initialization and granting cohesion, based on a functional approaching.
+
+For what it's worth, I actually had to hack inside ColReorder and add some code in there so I had to accomplish some integration between MF and CR.
+<h3>So, is there a need for better integration?</h3>
+Before I jump into the conclusion, I should say that <a href="http://www.sprymedia.co.uk/about" target="_blank">Allan</a> did a great job on building Datatables, it's a remarkable piece of software.
+
+I told him that I would risk being stupid to the point of being told to RTFM, but I stand for ease of read as well as ease of use. There should clearly be some plugin development guidelines and I personally volunteer to help build those guidelines. Based on what I know, <em>I would say there is a need to improve integration. If it's not for how it's built, it would by the way it's told.</em>