Placement of In-line editing feature within datatable

Placement of In-line editing feature within datatable

VermontBoundVermontBound Posts: 7Questions: 0Answers: 0
edited January 2013 in General
Hi,

I am following the inline editing blog for one of our requirements:

http://datatables.net/blog/Inline_editing

This works great, thanks. The only caveat is that we need the inline editor to always be on the top
of the datatable. Right now, it seems to always be on the bottom, which is not even viewable by the
user unless he does a reverse sort.

My questions:

1) How do I control whether the inline editing bar appears on the very top or very bottom?

2) How do I force the inline editing bar to **always** be on the very top of the datatable **no matter what**.
I ask this second one becasue somebody may be adding a new row in a filtered view (where the very top
or very bottom of the total records is not available).

I appreciate your responses, thanks!

Replies

  • VermontBoundVermontBound Posts: 7Questions: 0Answers: 0
    While I have your attention, I'd also be interested in finding out how to limit inline editing to one row only, not multiple rows. thanks again.
  • VermontBoundVermontBound Posts: 7Questions: 0Answers: 0
    I never have any luck getting a response on here :/. Anybody?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    I don't understand what you mean by 'on the top of the datatable'? The code presented in the demo puts the editing elements into the table, no under or over it. It is also worth pointing out that the code in the blog post is not a complete editing solution, its just a starter to show you how you might use the API to achieve such inline editing fairly simply.

    You might be interested in the more complete editing solution for DataTables, Editor: http://editor.datatables.net , which does have everything needed for editing, unlike the blog post.

    Allan
  • VermontBoundVermontBound Posts: 7Questions: 0Answers: 0
    Thanks Allan,

    Yes, I didn't clarify very well. The editing elements are, indeed, put into the table, but at the top of the rows - the first item at the top. How would I get the script to insert the editing elements at the other end (the bottom) of the table?

    Thanks a bundle for your response.

    Peter
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    I still don't understand I'm afraid. In the code in the blog post, if I click the 'Edit' on the middle row, the middle row becomes editable, not the top one.

    Allan
  • VermontBoundVermontBound Posts: 7Questions: 0Answers: 0
    Hi Allan,

    Ah, I see the confusion. OK, again, sorry for the lack of clarity.
    I am talking about adding "new rows" using inline editing, not editing current rows.
    Similar to the link I posted in the original question:
    http://datatables.net/blog/Inline_editing

    If you click on the "Add new row" link, an empty inline row gets added to
    the top row of the table. I want the same behavior, but I want to be able
    to add to the bottom row of the table (and limit the ability to add new rows
    to one time per submit, but I may be able to figure this one out).

    I hope I have done a better job of explaining?
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Oh - 'add data'! Well it's this code that relates to that:

    [code]
    $('#new').click( function (e) {
    e.preventDefault();

    var aiNew = oTable.fnAddData( [ '', '', '', '', '',
    'Edit', 'Delete' ] );
    var nRow = oTable.fnGetNodes( aiNew[0] );
    editRow( oTable, nRow );
    nEditing = nRow;
    } );
    [/code]

    So you need to alter the fnAddData to have it insert the new row wherever it is that you want it to appear in the table. That is determined solely by sorting. So if you want it at the end, you need to change it so that it will be sorted to appear at the end of the table.

    Allan
This discussion has been closed.