update the value of field in database in client side (Javascript)

update the value of field in database in client side (Javascript)

SarbastSarbast Posts: 85Questions: 0Answers: 0

Hello,

I would like to update the value of a field in database in client side. I did it in sever side, but I want the page to refresh after that. So, I thought this can be done when update in client side.

Thanks

Replies

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I would like to update the value of a field in database in client side

    You can update a table field by using cell().data() or row().data(). This won't update a database on the server.

    I did it in sever side, but I want the page to refresh after that.

    If you are using the ajax option to load the Datatable then you can use ajax.reload() to reload the Datatable from the server. If you are using a jQuery ajax request to update the server side database you could use one of the API's above to update the client side instead of reloading the full table using ajax.reload().

    If this doesn't help please provide more specifics about your solution so we understand exactly what you are doing to update the server database and how you want to update the client table.

    Kevin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Thanks Kevin,

    I updated the field in server side via preEdit, but the problem is I applied some css in client side and not update without refreshing the page.

    Regards

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    @Sarbast Is this still an issue? I'm not clear if your last comment found a solution?

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hi Colin,

    Yes still and not found solution yet.

    Regards

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Are you able to link to your page so we can see it please. I'm not clear if the issue is that the data is being updated, but the CSS isn't.

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    I have a field called 'Status' when user apply its document the Status become Pending. The Admin can either Confirm or Reject it. When Confirm The background of the Status field become Green and Red when Reject. In case of Reject, the user can edit the uploaded document so the Status become Pending again, but the background still Red and need to refresh the page to change it. I want to change background when become Pending without refreshing the page.

    Regards

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    No still in localhost. Yes the problem in CSS

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    I applied some css in client side and not update without refreshing the page.

    How are you applying the CSS in the client? Are you using createdRow or columns.createdCell? If so you problem will need to use rowCallback instead which runs each time the row is displayed.

    Kevin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Kevin,

    I try rowCallback, but the problem not solve.

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Then we will need to see the problem. Please provide a link to your page, you can PM Allan or Colin if you want to keep it private, or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Maybe post you relevant Datatables and Editor code here to see if something obvious stands out.

    Kevin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    I run the code in localhost so you are unable to access it. Below I explained my problem in details.

    I have a field called 'Status' when user apply its document the Status become Pending. The Admin can either Confirm or Reject it. When Confirm The background of the Status field become Green and Red when Reject. In case of Reject, the user can edit the uploaded document so the Status become Pending again, but the background still Red and need to refresh the page to change it. I want to change background when become Pending without refreshing the page.

    Regards

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Please post your relevant Datatables and Editor code so we can see what you have.

    Kevin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Kevin,

    The problem solved after I add CSS to "Pending" status in rawCallback.

    Thanks alot Kevin and Colin

Sign In or Register to comment.