jEditable + dynamicly generated datatable

jEditable + dynamicly generated datatable

klasycklasyc Posts: 5Questions: 0Answers: 0
edited June 2009 in General
Hi everybody,
I am an absolute beginner in jQuery and Datatables, but I like it very much. Recently I have encountered the following problem which I can't solve:

I have a simple datatable which is initially empty. Then I load data there via ajax (xml). This part works well. But then I need to edit the data, but jEditable pluging doesn't work. The edit box simply doesn't appear.

When I make a "static" table which is written directly in HTML, it can be edited. But when I add a row, it cannot be edited although the original rows can.

Please can somebody help me?

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi klasyc,

    The problem here is that the event handlers for jEditable are not being added to the elements in the table, because jEditable is being initialised before the table is drawn. A useful tool that you can use to view which elements have events attached is Visual Event: http://sprymedia.co.uk/article/Visual+Event .

    What you need to do in initialise jEditable on each draw of the table (since new elements are made for each draw in server-side processing). This can be done using the fnDrawCallback() function - http://datatables.net/usage#fnDrawCallback

    Hope this helps,
    Allan
  • klasycklasyc Posts: 5Questions: 0Answers: 0
    Thank You very much, the table works now through the callback function you have mentioned.
  • klasycklasyc Posts: 5Questions: 0Answers: 0
    Please one more question: When I edit the table, is it possible to edit some columns by a simple edit box while some other columns by a pick up list? If so, why?
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi klasyc,

    It might well be possible, but this is probably a question for the jEditable people. As I understand it, jEditable only uses text boxes for input, but I might be wrong. http://www.appelsiini.net/projects/jeditable might be your best bet for information on this. Failing that, perhaps a different edit in place plug-in would help.

    Regards,
    Allan
  • klasycklasyc Posts: 5Questions: 0Answers: 0
    Hi Allan,

    jEditable manages several types of editing widgets including pick up lists. The only problem is how to determine which column edit with which widget, I think. Maybe change the setting of the whole table in the callback function?
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi klasyc,

    Ah yes so I see: http://www.appelsiini.net/projects/jeditable/custom.html . So basically it comes down to the initialisation that you use. What you might be able to do is make use of jQuery selectors to change which columns get different jEditable initialisations. You could even use DataTables' sClass option to make make that selector nice and simple.

    If this is for a project which will be available to the public, would you be willing to add a little something to the "How are you using DataTables" thread ( http://datatables.net/forums/comments.php?DiscussionID=230 )? It sounds like quite an interesting application of jEditable and DataTables combined.

    Regards,
    Allan
  • klasycklasyc Posts: 5Questions: 0Answers: 0
    Hi Allan,

    thank You for Your replay, works great as expected. I use my home server to control my garden watering system. I am writing web interface to configure the watering schedule, server for downloading weather forecast etc. I think, it is obvious that the project won't be public (because I don't want to have a flood in the garden :-), but I will post some screenshots to the thread you have mentioned when I am finished.

    Best wishes
    Klasyc
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi Klasyc,

    That sounds like a very cool project indeed - and not one for public consumption ;-). Yes if you would be willing to post some screenshots - that would be great. Drop me a line if you want me to host this on this server.

    Regards,
    Allan
This discussion has been closed.