Editable tables & server side processing

Editable tables & server side processing

col.braziercol.brazier Posts: 26Questions: 2Answers: 0
edited March 2011 in General
Hi,

I would like to combine:

* editable tables
* server side processing
* add/delete rows

My example is at www.fobgfc.org/sq2.php

Any help would be appreciated.

Thanks, Colin

Replies

  • allanallan Posts: 63,113Questions: 1Answers: 10,395 Site admin
    Hi Colin,

    So the first issue I see with what you've currently got is that jEditable doesn't do live events unfortunately (there are a few discussions around if you Google for them, on how to make it do live events - but that is probably an optimisation that you can make at a later date :-) ). What you need to do is have the jEditable initialisation inside the fnDrawCallback (which you currently have commented out). That will add the jEditable plugin to the table.

    To add and delete rows, you'll probably want a button or something to trigger the event. What I tend to do when creating this kind of table is to use TableTools to have Add / Delete buttons and also deal with row selection (although I think in this case it might be better just to have a delete button on each row). From there you can add an event handler to the add and delete buttons which will fire of the XHR needed for each option.

    Allan
  • col.braziercol.brazier Posts: 26Questions: 2Answers: 0
    Allan, thanks for your reply. Using your advice I have tried a different route away from jEditable and serverside processing and have reverted to the DOM and jQuery as seen here:

    http://www.fobgfc.org/sqedit_07.php

    I need to add a "Save changes" button, but my main question is now, should I validate/update the whole list at once or just page by page? I know this might be getting away from being a purely Datatables question now but how/where can I attach an update event to the page numbering, if I should take the "one page at a time" route?

    Thanks again for your understanding!

    Colin
  • allanallan Posts: 63,113Questions: 1Answers: 10,395 Site admin
    HI Colin,

    With the approach you've taken of having all the editable fields in a permanently "editable" mode I'd suggest one of two different ways:

    1. Save on every edit - i.e. each click on the checkboxes is saved by sending an XHR to the server and the inputs could have a keypress for similar (you could use a setTimeout a bit like the fnSetFilteringDelay plug-in for DataTables to save DDOSing your own server :-) ).

    2. Have a 'Save' button which will apply all changes made (regardless of the page). I wouldn't have thought (as a user) that changing page or sorting etc would fire off a save (although if you did want to do it that way you could use fnDrawCallback).

    Hope this helps a bit!

    Regards,
    Allan
  • col.braziercol.brazier Posts: 26Questions: 2Answers: 0
    Allan,

    Ta again. Is the approach I've taken outdated? (you can be candid!).

    Colin
  • allanallan Posts: 63,113Questions: 1Answers: 10,395 Site admin
    No I think it's a perfectly fine approach to take. What I think I personally would do (without knowing the background for your target users etc, so take it with a pinch of salt :-) ) would be to have a display mode where the information is easily readable and an editing mode where everything is editable. You've got the latter already. Of course if it is expected that the majority of interaction with the table will be editing, then just having it in edit mode all the time seems reasonable to me.

    Allan
This discussion has been closed.