Announcement

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

    Dropping a ListGridRecord onto a ListGrid that is grouped?

    SmartClient Version: v9.1p_2014-03-20/PowerEdition Deployment (built 2014-03-20)
    SmartGWT 2.5.1
    IE-11

    Is there a way to re-parent a ListGridRecord dragged from another ListGrid and dropped to a ListGrid that is grouped?

    I see a re-parenting example using a TreeGrid. But I can't find an example for a ListGrid that is grouped?
    Last edited by JLivermore; 10 Apr 2014, 06:16. Reason: clarity

    #2
    This isn't built in, but could be achieved easily via a custom record-drop handler which looks at the target record / target index and determines which group the user dropped into.

    Regards
    Isomorphic Software

    Comment


      #3
      How do I add a ListGridRecord to a particular group? What is the ListGrid method to add a ListGridRecord to a particular group?

      Is it a matter of

      Code:
      ListGridRecord[] data = ListGrid.getData();
      List list = Arrays.toList(data);
      list.add(ListGridRecord);
      ListGrid.setData(list.toArray())
      And let the configured ListGrid for grouping manage the merge?
      Last edited by JLivermore; 10 Apr 2014, 09:15.

      Comment


        #4
        We're assuming you're working with a databound listGrid here (correct us if you're not!)

        The right way to add data is to call the addData() API to add the record to the dataSource for the grid.
        To ensure it goes into the correct group, you'll first want to set the value of the appropriate field (the field you're grouping by) to the group value of the group you're dropping into.

        Regards
        Isomorphic Software

        Comment


          #5
          Yes, I am working with a databound ListGrid. All the records begin in this grouped ListGrid, then the user drags records around to other ListGrids, and then they drag them back to the original Grouped ListGrid. So the grouping fields are all set, and never change.

          Currently my DropHandler simply checks if the ListGrid is grouped, then it ungroups it. Which does not look pretty in the UI when dropping onto a grouped ListGrid.

          So instead, I should simply do a ListGrid.addData() with the dropped records.

          Comment


            #6
            Much better, thanks:

            Code:
            availableGrid.addDropHandler(new DropHandler(){
            
                        public void onDrop(DropEvent event) {
            
                            //if(availableGrid.isGrouped()) availableGrid.ungroup();
                            if(targetSelection != null)
                                for(ListGridRecord listGridRecord : targetSelection) {
                                    availableGrid.addData(listGridRecord);
                                }
                        }
                    });

            Comment


              #7
              Is it possible to drag and drop Groups (and ListGridRecord contained in that Group)?

              Comment


                #8
                Unfortunately this isn't something we currently support. The Group-header nodes aren't selectable, and dragging works on the selected records.
                It would be possible to achieve with entirely custom drag handlers, or you could consider using a TreeGrid instead of a grouped ListGrid in your UI.

                Comment


                  #9
                  CustomDragHandler, thanks. How would you get all the ListGridRecords in a Group-header node?

                  Comment


                    #10
                    groupNode.getGroupMembers() should do it

                    Comment

                    Working...
                    X