Announcement

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

    ListGrid drag handler

    I'd like to add my own logic for when the user drags a record for reordering. I can't find anything in the documentation - could you please tell me if there is a way to do this?

    #2
    Use the ListGrid.recordDrop event - it has extensive docs on what it does by default and how to cancel that behavior.

    Comment


      #3
      Thanks I was only looking from "drag" methods that's why I missed it during my search. Another question I have - is there anyway to manipulate the selectItem to have this behaviour?

      Comment


        #4
        The SelectItem "pickList" is a subclass of ListGrid, so yes, you could use pickListProperties to apply canReorderRecords and a recordDrop handler to it.

        Be aware that you're moving into slightly uncharted territory (there is some specialized event handling for pickLists which shouldn't impact drag/drop directly but does of course impact things like record click).
        If you find you can't get the behavior you're after with these properties, let us know what you're trying to achieve and we may be able point you in the right direction.

        Comment


          #5
          Ok. Currently we are using select item to show the valuemap in multiple lines. Problem is in order to do this we had to set "multiple" to true - I can easily ignore the multiple selections but if I drag one record through the select item's body, it automatically selects the records I hover over.

          Ultimately, we want to have a control in which the user can specify the sort order of the value map by drag/drop within the same control. We would then save this new sort order in the database for when this valuemap is used elsewhere. This valuemap would never be a big list which is why I am trying to make it work on a select item instead of using a listgrid - our select items are not bound to a datasource whereas our listgrids are, which would cause an extra server call separate from our own data updates.


          Code:
          isc.DynamicForm.create({
              width: 500,
              fields: [{
                  name: "shipTo", title: "Ship to", type: "select",height: 100,multiple:true,multipleAppearance :"grid",  
                  pickListProperties:{canReorderRecords:true,selectionType:"single",
                  recordDrop:function(dropRecords, targetRecord, index, sourceWidget){isc.warn('recorddrop');}},
                  valueMap: {
                      "US" : "<b>United States</b>",
                      "CH" : "China",
                      "JA" : "<b>Japan</b>",
                      "IN" : "India",
                      "GM" : "Germany",
                      "FR" : "France",
                      "IT" : "Italy",
                      "RS" : "Russia",
                      "BR" : "<b>Brazil</b>",
                      "CA" : "Canada",
                      "MX" : "Mexico",
                      "SP" : "Spain"
                  },
                  imageURLPrefix:"flags/16/",
                  imageURLSuffix:".png",
                  valueIcons: {
                      "US" : "US",
                      "CH" : "CH",
                      "JA" : "JA",
                      "IN" : "IN",
                      "GM" : "GM",
                      "FR" : "FR",
                      "IT" : "IT",
                      "RS" : "RS",
                      "BR" : "BR",
                      "CA" : "CA",
                      "MX" : "MX",
                      "SP" : "SP"
                  }
              }]
          });

          Comment


            #6
            If drag and drop is allowed in a pick list, this has a number of subtle consequences like not being able to act on a click until mouseUp, and weird cases with modality. The simplest thing is to add an icon or similar control that opens a separate grid in a window to do reordering.

            Comment

            Working...
            X