Can the table *not* refresh after an edit?
Can the table *not* refresh after an edit?
I have a DataTables+Editor table with rows that have three inline editable fields. I can think of two situations where I would not want the table to refresh after making an edit:
I have a filter on one of the columns through SearchPanes. I edit that column for one row. That row disappears after the edit because it no longer belongs to the current filter. But I still wanted to make an edit on a different column of that row. So now I have to change the filter to go find the row again.
Again, filtered through SearchPanes. I make an edit, but click the wrong option in
select
by mistake. The row disappears, so I have to change the filter to go find it again to fix the mistake.
Ideally, after the edit, the Datatables table would receive confirmation that the edit went through so that it can show the new value, but the row wouldn't disappear or be sorted to a new location until the user click a reload button or changed the filter.
Is this possible?
Answers
Check out this thread to see if it helps.
Kevin
Hmm, it seems like that's the option I need, but it isn't working.
drawType: none
does do something in that the database is updated with the new value, while the old value is shown on the browser and the row stays put.But I want the new value to be shown and the row to stay put. When I try
drawType: page
it's the old behavior, where it re-sorts after an edit.Here's the page with
drawType: page
enabled, if you want to look at the code. (I'm on a phone so it's tough to copy here.) Editing won't work, though, unless you're logged in.https://comprehensibleinputwiki.com/ciwlibrary/vidadmin.php
Also, I couldn't find details on the
page: current
that the other thread mentioned.Wait, that's weird. With
drawType: none
, it works how I want, but only after I edit the cell to the new value twice. Then it shows the row with the new value but still in the same position.You have server-side processing enabled, so any display of data needs to come from the server. The
drawType: 'none'
option for Editor will simply disable Editor writing to the client-side fields, since the next thing that would happen would be a round trip to the server to get the new data.edit This paragraph is wrong - see next post. Perhaps in server-side processing mode and when
drawType
isnone
then it should update the table... I've got that noted for the next release. If you want to get that working locally, in the Editor source search for:and remove the first part of that condition. That isn't exactly what I described, but it will do in your use case.
Regards,
Allan
Hmmm - I was editing the code, when I realised that the second part of the condition should actually handle this case already - so ignore what I said above.
Can you give me write access to your page and also use the non-min version of DataTables.js please? I'll see what is going on here.
Allan
Sure, let me code up something to give you write access.
Ok, you can just make edits without logging in now. Feel free to edit anything, I'll just undo the edits from non-logged in users later.
Something else going on here. If I take the "Portuguese Digs" channel and have it with difficulty not set when I load the page, then edit the difficulty:
However, the response from the server contains:
However, if I then reload the page I can see that the difficulty was set.
So the issue is that the difficulty is being set either after the server-side libraries have read the value, or it is being set in a different transaction.
I'd need to see your PHP code to know for certain, but a quick thing you could try (if it is a transaction issue) is to add
->transaction(false)
just before the->process(...)
call. It isn't the correct fix, but it would let us check without me seeing the code.Allan
Oh, ok, so it's probably because I'm using functionality similar to the logging changes example to edit the rows, instead of directly through the library.
I set transaction to false, and here is the php code:
The data for the table is coming from the secondary tables which are updated in logChange().