jQWidgets Forums

jQuery UI Widgets Forums Grid Format a new row received like the data adapter does

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 5 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • ajcs
    Participant

    I am using a datasource/dataadapter and a grid. In the data source I give the data types like number and date etc and all is working fine.

    I am accumulating changes to multiple rows in the grid and then doing my own ajax call to backend to save the data. All is working fine and I am returning the saved rows back from the server (because backend validation might have made changes too) and I am updating those rows in the grid with the latest data.

    I am getting the data back from the server in json format but of course all the fields are strings and not in number/date format like the data adapter has put them in to. I could of course format the data myself but my question is: Can I call a function in the data adapter to format my new row?

    There must be a routine in your data adapter that converts the data types for each row so I wonder if I can call it?


    Hristo
    Participant

    Hello ajcs,

    To update data in the jqxGrid it will be better to use the updatebounddata method.
    About the CRUD scenario I would like to suggest you look at this tutorial below, if you use another environment then I would suggest you another tutorial:
    https://www.jqwidgets.com/jquery-widgets-documentation/documentation/asp.net-integration/asp.net-grid-crud.htm?search=
    It uses the addrow, updaterow, and deleterow callback for this case.
    Especially for the mentioned case, I would like to suggest you look at this example:
    http://jsfiddle.net/jqwidgets/dRbAE/
    Instead of the localdata member in your case, you should use the url member and the mentioned method above should update the jqxGrid with the newer records.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    ajcs
    Participant

    Yes I already looked at that example before I wrote that code. It seemed to me (correct me if I am wrong) that it has the following drawbacks:

    1. When updatebounddata gets called and it sends the data to the server if you fail validation on the server there is no way to handle that and stay in edit mode. You either have to commit and accept wrong data or do not commit and loose data edits. UI will always be simple validation but the server will have more validation that could fail so the user needs to make more edits.

    2. If you want to allow the user to edit multiple rows before saving the data then the save will have to be manually controlled.

    3. When you have cell edits which have dependencies to other fields they need to make changes to other data in the row then you need to use updatebounddata to find if the cell has really changed since geteditorvalue and cellendedit do not tell you if the user pressed escape so you don’t know to update the other fields or not. So that means using editmode: ‘selectedcell’ so you could not use updatebounddata to save the data because the row is not ready to be sent yet because that is called for every cell.


    Hristo
    Participant

    Hello ajcs,

    Could you provide us with one simplified example that demonstrates your case?
    If you make a validation on the Server-Side then you should handle this case on that side.
    I would like to ask you for more details about the second point.
    Also, I will include that there is a updaterow method which could be used to update just one row as well as to update many rows.
    About the third point, it seems that we already have a similar forum topic.
    Could you clarify what is your final goal?
    On the end, I would like to suggest you look at this demo:
    https://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/rowediting.htm?light
    I would like to propose your attention to the Ship Date” column.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.