We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15083
    • 697 Posts
    "Little" off topic, but MIGx is the only example I can find of this functionality.
    I am trying to add drag and drop functionality to a MODx.grid

    To the grid I have added:

             enableDragDrop: true // enable drag and drop of grid rows
            ,ddGroup : 'mygrid-dd'
            ,viewConfig: {
                emptyText: 'No items found',
                sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
                forceFit: true,
                autoFill: true
            }


    I then addedt he listener you wrote for MIGx:

    listeners: {
                "render": {
                    scope: this,
                    fn: function(grid) {
    
                    // Enable sorting Rows via Drag & Drop
                    // this drop target listens for a row drop
                    //  and handles rearranging the rows
    
                      var ddrow = new Ext.dd.DropTarget(grid.container, {
                          ddGroup : 'mygrid-dd',
                          copy:false,
                          notifyDrop : function(dd, e, data){
    
                              alert('Hello world!');
    
                              // NOTE:
                              // you may need to make an ajax call here
                              // to send the new order
                              // and then reload the store
    
    
                              // alternatively, you can handle the changes
                              // in the order of the row as demonstrated below
    
                                // ***************************************
    
                                var sm = grid.getSelectionModel();
                                var rows = sm.getSelections();
                                if(dd.getDragData(e)) {
                                    var cindex=dd.getDragData(e).rowIndex;
                                    if(typeof(cindex) != "undefined") {
                                        for(i = 0; i <  rows.length; i++) {
                                        ds.remove(ds.getById(rows[i].id));
                                        }
             							ds.insert(cindex,data.selections);
                                        sm.clearSelections();
                                     }
                                 }
        						grid.collectItems();
    
    
                                // ************************************
                              }
                           })
    
                    this.setWidth('99%');
                    //this.syncSize();
                               // load the grid store
                              //  after the grid has been rendered
                              //store.load();
                   }
               }
            }


    Problem: I get the click and drag of a row (Ie it says 1 row selected) but I I never the the drop green arraow? Its like the drop area if not defined, so I cant complete the action?

    Any help much appreciated smiley
    MIGx rocks smiley
      • 4172
      • 5,888 Posts
      hmm..

      can nothing see, what should be wrong.
      added your code to a MIGXdb - grid and got the 'Hello world' alert.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 15083
        • 697 Posts
        What I might do is this then:

        - Start with the MIGx grid as a base (because I know that works), and work backwards smiley

        I'll add my columns and data to the KIGx grid and report!!
        Thanks for the help Bruno.
          • 23018
          • 353 Posts
          Arghhh. I wanted to modify my question regarding MIGX and the usage of &where.

          Instead of "modify" I hit "remove". It was gone in an instant. No confirmation dialog, nothing. This is either some kind of sick humor or an epic fail in usability. Any idea where I can scream out my frustration?

          To sum up the lost post: The &where parameter isn't working in latest REVO/MIGX.

          &where=`{"name:=":"John Doe"}`


          Shows up no results.

          Please confirm or prove me I'm wrong.

          It also seems to be impossible to pass a paramter to the MIG &tpl

          [[!$contactinfo? &contact=`John Doe`]]
          
          contactinfo Chunk
          --------------------------
          <ul class="reset">
            [[!getImageList?
              &docid=`120`
              &tvname=`contactinfo migx`
              &tpl=`contactinfo.migx.tpl`
              &contact=`[[+contact]]`
            ]]
          </ul>
          
          contactinfo.migx.tpl Tpl Chunk
          --------------------------------------------
          [[+name:is=`[[+contact]]`:then=`
          <li>
            <dl class="reset">
              <dt>No</dt><dd>[[+idx]]</dd>
              <dt>Name</dt><dd>[[+name]]</dd>
              <dt>department</dt><dd>[[+dep]]</dd>
              <dt>Title</dt><dd>[[+title]]</dd>
              <dt>Telephone</dt><dd>[[+telephone]]</dd>
              <dt>Email</dt><dd>[[+email]]</dd>
              <dt>Photo</dt><dd><img src="[[+photo]]" alt="[[+name]]" title="[[+dep]]"/></dd>
            </dl>
          </li>
          `:else=``]]
          


          The +contact Property is not processed inside the MIGX tpl.

          Regards,

          pepebe

          @Bruno: Please add your print_r_json snippet to the MODX package. I think its extremely useful. And get a "Buy me a beer" paypal button somewhere so we can treat you to something good... [ed. note: pepebe last edited this post 14 years, 8 months ago.]
            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
            • 4172
            • 5,888 Posts
            forgot to add the $where in migx/model/migx.class.php

            function filterItems($where,$items)


            you can use the property - placeholders:

            [[+property.contact]]
            

              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 23018
              • 353 Posts
              I added the $where parameter to core/components/migx/model/migx/migx.class.php line 282 as Bruno17 recommended.
              I changed:
                  function filterItems($items)
              To:
                  function filterItems($where,$items)
              

              This fixes the &where issue. smiley


              The property placeholder also worked as Bruno17 promissed. smiley


              Now I can add a bit here and there and i get downloadable vcards as well as microformated contact information all at the hands of my editors. Neat.

              @Bruno17: Thanks for your support.

              @anyone: Whats the largest MIGX grid you are using? Any experience/advice regarding performance? [ed. note: pepebe last edited this post 14 years, 8 months ago.]
                Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                • 4172
                • 5,888 Posts
                If you have lots of records, I would use a custom-table or childresources
                both can be managed with the new MIGXdb (github-version should work so far)
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 23018
                  • 353 Posts
                  Just a quick note for those running into problem with their json grid or form strings.

                  Use http://jsonlint.com/ for checking your json syntax.

                  Regards,

                  pepebe



                  [ed. note: pepebe last edited this post 14 years, 8 months ago.]
                    Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                    • 34459
                    • 134 Posts
                    Hi,
                    I have a bizarre problem. I am using one template for all of my pages, so through form customization I've assigned specific tv's (migx) to my template by resource id. The thing is that when I edit any resource I don't get every tv assigned to it(always the last one is missing). The funny thing is that the page it self, is intact and working
                      Check out blackflow.pl
                      • 19369
                      • 1,098 Posts
                      Hi,

                      Is there a way, in the Grid Columns, to show the name and not the value of the "Listbox (Single Select)" TV?

                      This discussion is closed to further replies. Keep calm and carry on.