I love DataTables, and have used it in a previous project and knew I would use it in the newer version of this project too. Looking forward to DT2.0...need beta testers? Now that I'm a little more familiar, I'm trying to get at some advanced features and they aren't working the way I have in mind. I had started out with a fairly basic implementation of DataTables. Data is already presented in table format, $('#testTable').datatable() made it spiffy and awesome. While using this static data, I implemented a great way to add/edit/delete rows from the table as needed. All is well and good with the 'static' data source. However, with an AJAX source the experience is not consistent.
What I've run into is my previous AJAX data handling seems to be conflicting with DT's desire to manage itself. Since I've gone through all the work to properly (in my eyes) manage the addData, updateData and deleteRow, I would prefer to use that over how DT wants to reobtain the data, yet still let DT mange the data *only* if it comes through the search filter input. So, let me control add, edit, and delete, but if I search for something within the table, DT can handle requesting the new data.
I think part of the issue is that when I trigger an XHR to, add a row, DT 'senses' the request and, even though I've added the data to the table as part of the beforeSend handler, DT requeries the entire table instead of just waiting to see if the request had a problem. As a side note: In my case it's better to be optimistic in these cases and add/edit/delete the data in the table but be able to revert only if the request fails. Since success is the most likely outcome and this way the user sees the action happen right away instead of waiting for the request to complete, it allows for a good user experience. The issue is similar to both edit and delete where the DT actions don't take place (yet the XHR is successful) and for delete, it doesn't remove from the table at all and with edit, it restores the original content perhaps from some kind of internal cache.
tl;dr
DataTables is awesome.
How can I manually mange rows (adding, editing, deleting) while using an AJAX datasource and only redraw/requery for data if there's input to the table filter? My data management handlers are being overridden/ignored in favor of just requesting all the data again. Is there a combination of bServerSide, bProcessing, sAjaxSource or some kind of event handler function that will accomplish what I'm after?
As an aside, I found a neat feature where taking an existing table with data, and setting bServerSide to false, and setting iDeferLoading loads all the visible data twice. Bug report to follow...soonish.
What I've run into is my previous AJAX data handling seems to be conflicting with DT's desire to manage itself. Since I've gone through all the work to properly (in my eyes) manage the addData, updateData and deleteRow, I would prefer to use that over how DT wants to reobtain the data, yet still let DT mange the data *only* if it comes through the search filter input. So, let me control add, edit, and delete, but if I search for something within the table, DT can handle requesting the new data.
I think part of the issue is that when I trigger an XHR to, add a row, DT 'senses' the request and, even though I've added the data to the table as part of the beforeSend handler, DT requeries the entire table instead of just waiting to see if the request had a problem. As a side note: In my case it's better to be optimistic in these cases and add/edit/delete the data in the table but be able to revert only if the request fails. Since success is the most likely outcome and this way the user sees the action happen right away instead of waiting for the request to complete, it allows for a good user experience. The issue is similar to both edit and delete where the DT actions don't take place (yet the XHR is successful) and for delete, it doesn't remove from the table at all and with edit, it restores the original content perhaps from some kind of internal cache.
tl;dr
DataTables is awesome.
How can I manually mange rows (adding, editing, deleting) while using an AJAX datasource and only redraw/requery for data if there's input to the table filter? My data management handlers are being overridden/ignored in favor of just requesting all the data again. Is there a combination of bServerSide, bProcessing, sAjaxSource or some kind of event handler function that will accomplish what I'm after?
As an aside, I found a neat feature where taking an existing table with data, and setting bServerSide to false, and setting iDeferLoading loads all the visible data twice. Bug report to follow...soonish.