submit full row data with select lists

submit full row data with select lists

DaveNavarroDaveNavarro Posts: 18Questions: 7Answers: 0

Hello,

I have a table / editor with 5 columns set as type: select and the editor is set to use inline editing.

I wish to allow a user to make changes to one or more values (cells) in the row and then submit all changes at once.

The trouble I'm having is that the editor is only tracking 1 field change at a time. If I make a change to the value in column one (via the select list) and then move and change the value in column two... then save, only the last value changed is passed back.

The other changes are not being submitted with the save event.

What should I do to correct this behavior?

Please let me know and thanks,

~ Dave

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I'm afraid that a buffered submit is not something that Editor supports at this time. It needs to submit the data on each edit. You could potentially provide a custom ajax function that would create that buffer, but it isn't something that is built in (yet - I hope to add in in a future version, although that might be a little way off).

    Allan

  • DaveNavarroDaveNavarro Posts: 18Questions: 7Answers: 0

    Hello Allan,

    Thanks for the quick reply.

    Is it possible to edit the existing rows cell data? If so, perhaps I can simply place the selected value (Id) in the appropriate table cell.

    When I submit, I can get the changed values from the data.data[key] like this;

    VendorOptionId: data.data[key].VendorOptionId

    Would this be possible?

    Please let me know and thanks,

    ~ Dave

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    As in use DataTables as the data store? That isn't something that is built in to Editor at the moment, but will be available in 1.6 (this summer). Until then, you would need to use ajax to provide a custom function for this. If you were to use the submit option of the form-options object to submit the full row, you could just send that back - something like:

    ajax: function ( method, url, data, success, error ) {
      // NOTE - THIS WILL WORK FOR EDIT ONLY AS IS
      if ( data.action === 'edit' ) {
        success( { data: $.map( data.data, function ( val, key ) {
          val.DT_RowId = key;
          return val;
        } } );
      }
    }
    

    It's a little cheeky, but that should work (i.e. it just passed back the submitted data as the "new" data). It may need a tweak, but I think that should work.

    You can then use rows().data() to get the data from the whole form and submit to the server for saving (although the provided PHP and .NET libraries wouldn't work for that, you'd need some custom code).

    Allan

  • DaveNavarroDaveNavarro Posts: 18Questions: 7Answers: 0

    Hello Allan,

    In the previous comment you indicate that the new feature "will be available in 1.6 (this summer)."

    Would you happen to know when 1.6 is scheduled to be deployed? I'd like to plan some changes around this update but need a date if possible.

    Please let me know and thanks,

    ~ Dave

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I don't have a firm date I'm sorry to say, which is why I was a bit vague above - I'm still working out the best path for the various pieces of work I have planned for the immediate future. Best I can really say is to keep an eye on the release feed or Twitter if you don't use RSS.

    Allan

  • DaveNavarroDaveNavarro Posts: 18Questions: 7Answers: 0

    Hello Allan,

    Thanks for all your help.

    I was able to take your suggestions and implement a solution that works very nicely.

    I can now edit all the data 'inline' (including multiple rows) and then submit all changes with a single submit.

    I even perform some data validation while cells are being edited and change the background to red if data is missing.

    I can share any snippets if you or anyone else would like to see.

    In any case, thank you again for helping out!

    Case closed. :-)

    ~ Dave

  • NagenddraNagenddra Posts: 3Questions: 1Answers: 0

    Hi, I am trying to do Inline editing could you please send the code thankyou

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    There are examples of how to do inline editing in the Editor examples.

    Allan

This discussion has been closed.