[CLOSED] Help with Drag & Drop in Partial View

Page 2 of 2 FirstFirst 12
  1. #11
    Thanks Fabricio

    You're absolutely right. Just need to know where the titles are going now!

    Thanks again

    Jeff
  2. #12
    Hello! The titles were not going very far. Actually they were right above all the time.

    Just remove the .Height(1000) setting from both panels and you'll see them keeping in place.
    Fabrício Murta
    Developer & Support Expert
  3. #13
    Thanks Fabricio

    That's great, I should be able to implement that in my application now. The height of 1000 was there intentionally and in the main application there's a piece of javascript which adjusts the height depending on the screen size and availability. That got missed out in the example.

    Presumably there's a better way of maximising the the height and width of a panel depending on the screen size?

    Thanks again

    Jeff
  4. #14
    Hello Jeff!

    Glad we're making progress here!

    As for height fitting I can suggest you a couple searches on our forums for solutions and use cases already discussed here. If you are having trouble choosing the best way then feel free to open a new thread so we can discuss it there in detail!
    - Search pattern 1: panel fit height
    - Search pattern 2: panel height 100%

    Hope this helps! I'm not sure at this point we got your initial issue solved here, we should clarify it and close this thread if we are good, or catch back up the main subject to effectively provide you an adequate solution.
    Fabrício Murta
    Developer & Support Expert
  5. #15
    Hi Fabricio

    Thanks very much for your help. I've now got it working in my application. It took a little while because the receiving GridPanel is filtered. However, once I had figured that out I was able to set the filtering parameter in the getDragDropText function:

        var getDragDropText = function () {
            var selection = this.view.panel.getSelectionModel().getSelection()[0];
            selection.set("ClientID", clientID);
            return selection.data.Name;
        };
    As for setting the height is concerned I think I'm quite happy with our current method:

    //Adjust width and height of screen size 
    var utSetSize = function (e, msg) {
        var size = Ext.getBody().getViewSize();
        if (msg == "MainHeader") {
            e.setWidth(size.width - 70);
        }
        else {
            if (e.width > size.width) {
                e.setWidth(size.width - 187);
            }
            if (msg == "GridPanel") {
                e.setHeight(size.height - 150);
            }
            else if (msg == "Elements") {
                e.setHeight(size.height - 175);
            }
        }
    };
    Your comments welcomed!

    Thanks again

    Jeff
  6. #16
    Hello Jeff!

    Awesome, I'm glad you are finally getting your application looking the way you want!

    As for the manual height adjusting, it is fine if it works for you. Sometimes getting grid panel heights working the way we want can be challenging! The only comment I may add here is that, by using fixed widths, once you switch themes (if you ever plan supporting it) chances are that the screen will no longer fit nicely.

    Even in our examples explorers we have been adjusting examples that didn't fit as new themes were our, and it is so nice to be able to use new themes as they are release to give the app a new look! :)

    I'm not sure this may really help, but it could be a worth try. @Master15 recently shared a window code that has several panels fitting each other. When I saw that I remembered your problem and thought (although needing to move to Razor syntax -- usually not difficult) it could be a nice solution for this case. @Master15's post is here.

    If you want to give it a try and have something else to ask, I'd ask you in return to open a new thread as I am already diverging this thread from its original question with my reply itself. We should keep different subjects on different threads to ensure it would be easier for other people to find solutions on same problems in the future! I usually see myself re-visiting some threads over and over and they give insightful reminders. :)
    Fabrício Murta
    Developer & Support Expert
  7. #17
    Thanks Fabricio

    I will certainly take a look at @Master15's approach. I will of course start a new thread if I have any queries!

    I would like to ask a further question if I may. More for my own understanding than getting the application working.

    I don't understand how this works:

                                .Listeners(l =>
                                {
                                    l.AfterRender.Handler = "this.plugins[0].dragZone.getDragText = getDragDropText;";
                                    l.AfterRender.Delay = 1;
                                })
    In practice I've decided to dispense with the notification event so I don't need to set getDragDropText but I do need to set ClientID which is my filtering property.

    Doing it as I have done obviously works but it's got some unnecessary code in it which I would like to avoid. I tried something like

                                .Listeners(l =>
                                {
                                    l.AfterRender.Handler = "setClientID(this)";
                                    l.AfterRender.Delay = 1;
                                })
    and

        var setClientID = function (view) {
            var selection = view.panel.getSelectionModel().getSelection()[0];
            selection.set("ClientID", clientID);
        };
    but that didn't work. It seems that I needed this.plugins[0].dragZone in the handler?

    Thanks

    Jeff
  8. #18
    Hello Jeff!

    As for how this works:
                                .Listeners(l =>
                                {
                                    l.AfterRender.Handler = "this.plugins[0].dragZone.getDragText = getDragDropText;";
                                    l.AfterRender.Delay = 1;
                                })
    The listener is bound to the grid's view. Right? So the AfterRender script will take place right when the grid's view is ready. It will then have this as the grid's view itself. From the grid view, gets the first plug in attached to it, which we are assuming it is the gridDragDrop, as there's no other plug in to the grid at that moment. That's for simplicity. In a more robust approach, one might traverse every plugins in the view (with a for or forEach loop) and check if that plugin matches the drag & drop type and only then make changes to it.

    You can get lots of useful info on what is what exactly by JavaScript side on the official Sencha docs. That's a comprehensive "online reference card" with all features and syntax on the JavaScript objects. The dragZone reached by the plugin reference above then haves its original implementation of the getDragText() method literally replaced to the one we defined above. This is equivalent to overriding an specific instance of the drag drop in view to build the string the way we want.

    When we do something like:
    function test() { do some test}
    
    var testRef = test; // notice! no parens!
    we can then just
    testRef();
    it will work like a reference to a function.

    But there's a gotcha in it all. If you open the links above about the DragZone and method, you'll se they are marked as private. I'm not really sure why the example I based on giving you the solution relied on that private ExtJS methods. Probably there was not a discern between public and private at the time the example was written and it then relied in that class and method, which works fine even nowadays. The risk on that approach is that Sencha might be changing this at any time without advance notice and will not consider this being broken as a "breaking change" as it was said not to rely on it from the beginning.

    Well, to this point I tried to explain most of the first code block you wanted to understand its purpose. Now I'll get to the rest of your question.

    In your function:
        var setClientID = function (view) {
            var selection = view.panel.getSelectionModel().getSelection()[0];
            selection.set("ClientID", clientID);
        };
    To me, what you are doing is:
    1. selection is the current first selected item in the panel's selection model
    2. set the 'ClientID' property in that selection item to the value on an undefined variable -- or just "set ClientID to 'undefined'".

    I didn't see there where you have clientID defined. Only argument you passed to the function is the view object. Is that clientID in global space, and reliably updated to the current ID it should have?

    As for the ClientID name, I understand this as being a mapping from C# to get the actual ID of a component when it is rendered on the user's opened page (in JavaScript). From code behind perspective, it is useful to get the ID of a component when you don't specify it with a [b].ID("foo")[/bar] property, and allows you to statically add write the ID on output JavaScript code when the Razor view is rendered.

    Perhaps you mixed a bit the concepts on what it rendered server-side and client-side on the page?..

    For example...
    var cid = "myClientID";
    gets rendered as is and

    var cid = "@(GridPanel1.ClientID())";
    Renders on the client page (before JavaScript is parsed) as (assuming that GridPanel.ClientID() C# function returns "ext_3281"):
    var cid = "ext_3281";
    Or I just missed where you defined clientID in your JavaScript code.

    I hope something here helps!
    Fabrício Murta
    Developer & Support Expert
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [CLOSED] render partial view
    By sharmav1 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 27, 2015, 2:36 PM
  2. [CLOSED] DOM Drag-Drop example initial drag height
    By electromorph in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 09, 2015, 12:36 PM
  3. Replies: 0
    Last Post: Jun 12, 2014, 12:11 PM
  4. [MVC] How to use a partial view in a window?
    By KBorkiewicz in forum 2.x Help
    Replies: 7
    Last Post: Nov 21, 2012, 11:11 PM
  5. [CLOSED] MultiSelect with drag and drop, Drop listener
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 30, 2009, 8:25 AM

Posting Permissions