Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:03:10+00:00 2026-05-29T04:03:10+00:00

I would like to drag a row from a JQGrid to a text input

  • 0

I would like to drag a row from a JQGrid to a text input field and add a column’s text from the dropped row to the end of the text in the input.

Obviously this is a long way from the answer, but dragging a row from a grid with this set up on it (where #inputTextField is a ‘droppable’ text field) results in the JavaScript error this.p is undefined:

$("#searchResultsGrid").jqGrid('gridDnD',
    {
         connectWith:   '#inputTextField"
    }
);

This is because the destination is obviously not a JQGrid and does not have this.p defined. I’ve tried a few different things…maybe there is a way I can ‘trick’ the drop event into working? Thank you so much for any help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:03:10+00:00Added an answer on May 29, 2026 at 4:03 am

    I figured it out!! First, make the grid rows draggable (this function should be called in your gridComplete grid event handler):

    function makeGridRowsDraggable() {
    
            var $searchResultsGrid  =   $("#searchResultsGrid"),
                $searchResultsRows =    $("#searchResultsContainer .ui-row-ltr");
    
            $searchResultsRows.css("cursor","move").draggable("destroy").draggable({
                revert:     "false",
                appendTo:   'body',
                cursor:     "move",
                cursorAt:   {
                                top: 10,
                                left: -5
                            },
                helper:     function(event) {
    
                                //get a hold of the row id
                                var rowId = $(this).attr('id');
    
                                //use the row id you found to get the column text; by using the getCell method as below, 
                                //the 'unformatter' on that column is called; so, if value was formatted using a
                                //formatter, this method will return the unformatted value 
                                //(as long as you defined an unformatter/using a built-in formatter)
                                var theValue = $searchResultsGrid.jqGrid('getCell', rowId, 'desiredValue');
    
                                //set the data on this to the value to grab when you drop into input box
                                $(this).data('colValue', theValue);
    
                                return $("<div class='draggedValue ui-widget-header ui-corner-all'>" + theValue+ "</div>");
                            },
                start:      function(event, ui) {
                                //fade the grid
                                $(this).parent().fadeTo('fast', 0.5);
                            },
                stop:       function(event, ui) {
                                $(this).parent().fadeTo(0, 1);
                            }
            });
        }
    

    Then, create droppable elements:

    function createDroppableElements() {
    
        $("#inputFieldOne, #inputFieldTwo").droppable({
            tolerance:  'pointer',
            hoverClass: 'active',
            activate:   function(event, ui) {
                            $(this).addClass("over");
                        },
            deactivate: function(event, ui) {
                            $(this).removeClass("over");
                        },
    
            drop:       function(event, ui) {
                            var theValue = ui.draggable.data('colValue');
                            theValue = theValue .replace(/<br>/gi,'; ');
                            console.log("dropped value: " + theValue );  
    
                            updateText($(this), theValue);
                        }
        });
    }
    

    Create a helper method to append text to text field (appending a trailing ‘;’):

    function updateText(txtTarget, theValue) {
    
        var currentValue = txtTarget.val().trim();
    
        if (currentValue.length > 0 
            && currentValue.substr(currentValue.length-1) !== ";") 
            currentValue = currentValue + '; ';
    
        currentValue += theValue;
    
    
        txtTarget.val(currentValue);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to drag and drop files from windows explorer onto my application
I would like to drag and drop from my application into a system folder,
I've got a list of nodes. I would like to add a drag-and-drop-to-rearrange feature,
I would like to drag and drop my data file onto a Python script
I would like to implement some Drag-select functionality into a project of mine but
I would like to allow the user to click within my UserControl and drag
How would I drag and drop something into a static control? It looks like
I have this code to get a row from a JTable that is generated
I would like to embed an image within a block of text. The image
I have a map image and I would like to be able to drag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.