editing a row will change more than one record

editing a row will change more than one record

luposkyluposky Posts: 7Questions: 3Answers: 0

First of all, Editor is a fantastic product ... i'm really happy to use it in my projects.

But now I have a specific case that is difficult for me to handle.

When a user modify a record, the Editor push changes to the server and the server save and return the modified record ... no problem for this.

But in my case this operation can cause a side-effect and modify more than one record. Others records in the grid remain in the old status ... how can I update it ?

Think for example of a list of user/amount($) and percentages. When I change the amount for one user, the percentages need to be updated ... (my case is more complicated, and I don't want to rely on client side calculations, but essential this is the mechanism I need).

Any suggestion or hints on how to made this work with the minimum amount of work ?

For example, the "row" object returned from the server on edit can be an array of objects? (I think the answer is actually not, but this will be a nice improvement that solve nicely my needs) .

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    Great question! Just to confirm, it is the return from the server that you need to be changed from its current behaviour? The actual edit is correct as it is?

    As it stands, you are correct, currently it isn't possible (without modification at least) for the Editor libraries to return more than one row - the "edit one row only" is very much hardcoded into both the server libraries and the client-side at this time (that will change!).

    However, what you could do is refresh the table once the data have been edited. The downside is that it will require an extra Ajax call, but it is fairly simple:

    editor.on( 'postEdit', function () {
      table.ajax.reload();
    } );
    

    (using the postEditevent and ajax.reload() method).

    The other option would be to modify the server-side script to return the modified data for the table and update it client-side using clear() and rows.add(). That would keep the requirement to just one Ajax call, but it would require a little extra coding.

    Regards,
    Allan

  • luposkyluposky Posts: 7Questions: 3Answers: 0

    Hi Allan,

    The actual edit is correct and the editor is beautiful product (I'm using it without problem with c# and webapi server side).

    It is just that my user-case is different ... in my case it was optimal if the response from the server can provide and additional array of 'affectedRows' in addition to the 'row' object just modified.

    I think for now I will use the table.ajax.reload() as a workaround, thanks for this suggestion.

    When the record is modified, there is a nice highlight transition effect on the modified row (I hope not to lose it with the ajax.reload()), it will be very nice to have the same effect on the others affected rows, just as a suggestion if you decide to implement this in a future release ...

    Thanks,
    Luca

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Thanks for your kind words :-). Is the the Editor .NET libraries you are using from the 1.4 beta, or your own?

    When the record is modified, there is a nice highlight transition effect on the modified row (I hope not to lose it with the ajax.reload())

    I'm afraid you will. That highlight transition is part of Editor, but using ajax.reload() will cause all existing rows to be removed and then replaced with the latest load from the server.

    The only option to keep that would be an affectedRow property as you suggest (thanks for the suggestion - I've added it to my list!).

    Regards,
    Allan

  • luposkyluposky Posts: 7Questions: 3Answers: 0

    Thanks for the infos ... I'm simply using the mvc webapi to generate the json needed by datatable/editor ... it is just so easy ...

    In server-mode things can be more complex, and I'm really excited to read that you are in the process of support the .NET platform out of the box, but at this time I really don't have time to test a beta product ...

    Regards,
    Luca

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi Luca,

    Thanks for your reply. Editor 1.4 will be out of beta in the early new year :-).

    Allan

This discussion has been closed.