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

    Best practice for reordering databound ListGrids?

    Hi Isomorphic,

    what's the suggested best practice for reordering databound ListGrids?
    I have set setCanReorderRecords(true) and I have a position column of type int.
    The reordering works fine in the client, but no DML is issued by the server.

    A forumsearch for setCanReorderRecords made me guess that I'll have to use a RecordDropHandler and edit the records of the ListGrid there.
    This is a very ugly thing to do as the changed records are sent one by one after a call to saveAllEdits(), so no (deferred) unique constraint is possible in the DB.
    Does ListGrid somehow support the DML generation out of the box or do I have to write a DMI class, most likely calling some Stored Procedure?


    This requires there to be a field in the DataSource where order can be persisted. There is now a sample of doing this in the Pro/EE Showcase for 3.1d builds under Grids -> Drag and Drop. The sample code will also work for prior versions.


      Hi Isomorphic,

      i tried it - and it works like a charm. Thank you very much.
      I'd like to add the following hints for someone also implementing this:

      I have a field "POSITION" in the DB (Oracle) holding the information. The field has a unique constraint set up like this:

      ALTER TABLE t_status ADD CONSTRAINT UC_status_position UNIQUE ( position ) [I]INITIALLY DEFERRED[/I];
      As the reorder is executed in one transaction it is possible to have the constraint - even though the updates are executed as separate DML.

      Then I add the column twice in the .ds.xml:

      <field name="POSITION" type="int" required="true" editorType="spinner">
      		<validator type="isUnique" errorMessage="Position must be unique!"></validator>
      <field name="POSITION_DND" nativeName="POSITION" hidden="true" type="int"></field>
      In my ListGrid I use the POSITION field for display, the drop handler uses POSITION_DND. That way the user still can edit the records and gets the "unique"-error message and the drop handler can do its work and is not bothered by the validator.

      Thanks again,