+ this.record_handler = function(e, event_type, record)
+ {
+ // elements in set
+ switch(event_type) {
+ case NEW_RECORD:
+ /* NOTE in fact we are doing a join here */
+ if (object.received_all)
+ // update checkbox for record
+ object.set_checkbox(record);
+ else
+ // store for later update of checkboxes
+ object.in_set_buffer.push(record);
+ break;
+ case CLEAR_RECORDS:
+ // nothing to do here
+ break;
+ case IN_PROGRESS:
+ manifold.spin($(this));
+ break;
+ case DONE:
+ if (object.received_all)
+ manifold.spin($(this), false);
+ object.received_set = true;
+ break;
+ }
+ };
+
+ this.record_handler_all = function(e, event_type, record)
+ {
+ // all elements
+ switch(event_type) {
+ case NEW_RECORD:
+ // Add the record to the table
+ object.new_record(record);
+ break;
+ case CLEAR_RECORDS:
+ object.table.fnClearTable();
+ break;
+ case IN_PROGRESS:
+ manifold.spin($(this));
+ break;
+ case DONE:
+ if (object.received_set) {
+ /* XXX needed ? XXX We uncheck all checkboxes ... */
+ $("[id^='datatables-checkbox-" + object.options.plugin_uuid +"']").attr('checked', false);
+
+ /* ... and check the ones specified in the resource list */
+ $.each(object.in_set_buffer, function(i, record) {
+ object.set_checkbox(record);
+ });
+
+ manifold.spin($(this), false);
+ }
+ object.received_all = true;
+ break;
+ }
+ };
+
+ this.query_handler = function(e, event_type, data)
+ {
+ // This replaces the complex set_query function
+ // The plugin does not need to remember the query anymore
+ switch(event_type) {
+ // Filters
+ case FILTER_ADDED:
+ case FILTER_REMOVED:
+ case CLEAR_FILTERS:
+ // XXX Here we might need to maintain the list of filters !
+ /* Process updates in filters / current_query must be updated before this call for filtering ! */
+ object.table.fnDraw();
+ break;
+
+ // Fields
+ /* Hide/unhide columns to match added/removed fields */
+ case FIELD_ADDED:
+ var field = data;
+ var oSettings = object.table.fnSettings();
+ var cols = oSettings.aoColumns;
+ var index = object.getColIndex(field,cols);
+ if(index != -1)
+ object.table.fnSetColumnVis(index, true);
+ break;
+ case FIELD_REMOVED:
+ var field = data;
+ var oSettings = object.table.fnSettings();
+ var cols = oSettings.aoColumns;
+ var index = object.getColIndex(field,cols);
+ if(index != -1)
+ object.table.fnSetColumnVis(index, false);
+ break;
+ case CLEAR_FIELDS:
+ alert('Hazelnut::clear_fields() not implemented');
+ break;
+ } // switch
+ }
+