Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Question: Best practice for serverside update of multiple selected records

    Hello Isomorphic,

    what is the suggested approach if I want to change several selected ListGrid records on the serverside?
    I could do
    1) RPCManager.startQueue();
    2) Iterate over selected records and generate n DSRequests
    3) RPCManager.sendQueue();

    like in http://www.smartclient.com/smartgwte...ctions_queuing.

    But this would mean n UPDATE-SQLs on the serverside.
    I'd like to transfer the PKs of the selected records in one request to the server and work with them there inside of a single SQL with Criterion(PK, inSet, <mySelectedRecords>).

    How is this best done?

    Thank you and best regards,
    Blama

    #2
    I found this thread (http://forums.smartclient.com/showthread.php?t=13609) from 2010, which makes the task sound complicated.

    Is it really the case?
    Couldn't I send the PKs as fetch(or another operation)-request with the PK-values as criteria and act based on the Criteria in a special operation binding? Of course, I'll have to return the changed rows with DSResponse.operationType="update" for the client side to reflect the changes.

    Thanks again,
    Blama

    Comment


      #3
      That thread has the right approach if you want to avoid separate SQL statements. It's not especially complicated. The current best API for this is to pass the list of IDs of the records to be updated to DataSource.performCustomOperation() and have server-side code put together an "update" DSRequest with AdvancedCriteria using the IN_SET operator. Be sure to set dsRequest.allowMultiUpdate to true.

      Comment


        #4
        Hi Isomorphic,

        thanks for the hint. I solved it as suggested with DataSource.performCustomOperation() and dsRequest.allowMultiUpdate(true) and did dsResponse.addRelatedUpdate() to show the changes on the client side.

        Without the dsRequest.allowMultiUpdate(true) I had the strange situation that my Criteria where dropped from the request. Adding allowMultiUpdate(true) solved it, in case somehow hits this behaviour, too.

        Best regards,
        Blama

        Comment

        Working...
        X