0

In my project I am using the jQuery Datatables plugin and I have implemented the Column Filter and the Editable plugins. All the latest releases.

The problem is that after adding new values to the table (via adding a new record or updating an existing) the drop-down filter for the respective column does not get updated. I.e. the select remains unchanged no matter what changes are applied to the records in the table.

During my research I have found a demo (http://jquery-datatables-editable.googlecode.com/svn/trunk/columnFilter.html) which demonstrates the integration of the above mentioned plugins, but only with text box filters. So I have downloaded this web page and tried to only alter a text filter to select. However this was without success.

Sam
  • 7,252
  • 16
  • 46
  • 65

2 Answers2

0

You need to re-set the editable functionality whenever the table rows change.

  1. $('.editable').editable('disable');
  2. Re-initialize with new select options

You can see how you to implement the enable/disable functionality in this page: How to Enable/Disable JEditable

Community
  • 1
  • 1
Alex Tselegidis
  • 155
  • 1
  • 12
  • Thank you for your prompt response. Regrattably it does not solve my problem. I am not sure if you have understood that I am using Editable to edit the rows and not JEditable. Therefore I am not initializing JEditable and the implementation of the given enable/disable functionality is not possible. – Martin Wörgötter May 02 '13 at 09:08
  • My bad ... :( Still, I think that your problem relies on not re-initializing your dom elements. For example try to detroy and re-create the datatable with the editable functionality. Might not be the best solution but at least is something. – Alex Tselegidis May 02 '13 at 15:51
  • According to this issue: http://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=119 it is not possible to successfully re-create the datatable with the Column Filtering plugin. – Martin Wörgötter May 03 '13 at 07:57
0

I solved the problem by changing the Column Filtering plugin source code. I replaced line 397 with this code:

if (oSettings.iDraw == 2 || ajaxCall == true && oSettings.sAjaxSource != null && oSettings.sAjaxSource != "" && !oSettings.oFeatures.bServerSide) { if (iColumn == 3) { ajaxCall = false; }

Where iColumn is compared with 3, because the first drop-down is in the fourth table column. Next the variable ajaxCall states that some row was edited, added or deleted. Because whenever an ajax call for this purpose is made I change the variable to true. To be safe I initialise the variable as false before the plugin source code is read.