Copying the value of a datagrid column in EasyUI is a simple task that can be

<script type="text/javascript">
    var tbIndex = undefined
    var tbData = undefined

    $('#dg').datagrid({
        onClickRow:function(rowIndex,rowData){
            tbIndex = rowIndex
            tbData = rowData
        },
        onClickCell:function(rowIndex,field,value)
        {
            if(field == 'type' || field == 'name' || field == 'card' || field == 'money')
            {
                var t = $('#dg').datagrid('selectRow',rowIndex)
                console.log($(t).html())
                ZeroClipboard.config({moviePath: "{{ URL::to('/') }}/images/ZeroClipboard.swf"})
                //copy contents()
                var client = new ZeroClipboard($('#dg').datagrid('selectRow',rowIndex));

                client.on( 'load', function(client) {
                    //alert( "movie is loaded" );
                    client.on( 'datarequested', function(client) {
                        client.setText(this.innerHTML);
                    } );

                    client.on( 'complete', function(client, args) {
                        alert("copy complete:" + args.text );
                    } );

                } );
            }

        }
    })

I am looking to enhance functionality by enabling users to click on a column and copy the contents of that specific column.

Answer №1

Perhaps you can try implementing something similar to this:

$('#myTable').table({
    onCellClick:function(rowNumber,columnName,cellValue) {
         var rows = $('#dg').table('getRows');
         var results = [];
         for (var i=0; i<rows.length; i++) {
             if (columnName == 'category') {
                results[i] = rows[i].category;
             } else if (columnName == 'name') {
                results[i] = rows[i].name;
             } else if (columnName == 'quantity') {
                results[i] = rows[i].quantity;
             } else if (columnName == 'price') {
                results[i] = rows[i].price;
             }
         }
    }
});

By using this method, you will retrieve the values of rows in the same column as the cell you have clicked.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for running a dry default with Angular CLI

Query: Can dry-run be set as the default in a configuration? Purpose: Enabling dry-run by default simplifies the learning process by minimizing clean-up tasks if the command is not correct. This can encourage users to always perform a test run before exec ...

Utilizing the dollar shorthand for jQuery in conjunction with Selenium

While utilizing the Selenium addon along with jQuery in my project, I encountered an issue where the use of jQuery functions containing $ in Selenium would trigger a "function not found" error. The problem was resolved by removing jQuery, but using jQuer ...

Providing a public API that exclusively grants access to requests originating from my own website

After hours of scouring Google and SO, I have yet to find someone facing the same challenge I am encountering now. Here's the situation: We have invested a significant amount of money and effort into maintaining a database. The data from this databas ...

It is impossible to add a new element between two existing elements that share the same parent

I'm attempting to place an <hr> tag between the first and second .field-container. Because they have the same parent, I thought using element1.parentNode.insertBefore(element2, ...) would be the solution. However, it is not working as expected a ...

A simple way to initiate an AJAX call once the page has completed loading is by using the `window.location.href` as the

I encountered an issue with my event listener setup function navBtn() { $('#navBtn').on('click', (event) => { window.location.href = 'someotherfile.html'; myAJAXrequest(); }) } The problem I'm facing is that ...

Interacting with a Web API using JavaScript following successful authentication with Azure AD B2C

Currently, I am working on a .Net Web App. After going through the authentication process with Azure AD B2C using the Azure AD Connect protocol, my app's controller successfully obtains an access token via the MSAL library (written in C# code) to conn ...

How to Process a Stripe Payment using jQuery AJAX (JavaScript Only)

I'm in the process of creating a custom payment form for Stripe and I want to manually initiate the AJAX call to connect with Stripe. Instead of relying on a typical submit event. Unfortunately, it seems like I might be sending the request to the inc ...

Searching Categories with jQuery: Explore Remote Results and Cache System

Seeking to enhance user experience on my website, I have decided to implement the JQuery Category Autocomplete plugin. This will enable users to search through categorized results stored in a separate file at "/search_basic.php" (details of the file's ...

Retrieve JSON data within an HTML element, where the element is sourced from an AJAX GET response

What is the best way to extract JSON data from the response below? $.get('http://localhost:8000/json', function(response) { alert(response); }); The response is as follows: <div id="dom-target" style="display: none;"> {"logo":"log ...

What is the best way to extract and process CSV data from a JavaScript array of strings to incorporate into d3 visualizations?

I am looking to utilize data stored in a JavaScript array of strings to create a d3 graph that showcases a time series of timestamp (t), receive (rx), and transmit (tx) counters. Each element in the array represents one line of time, rx, tx data with comma ...

Different ways to showcase a value from the CSS file on the console using console.log

In this guide, you can learn how to create a custom directive in Angular by following this tutorial: Custom Directive Tutorial. The directive should function as intended. Still, I want to see the color value set in the CSS file displayed on the console us ...

What is the best method for retrieving an item from localstorage?

Seeking advice on how to retrieve an item from local storage in next.js without causing a page rerender. Here is the code snippet I am currently using: import { ThemeProvider } from "@material-ui/core"; import { FC, useEffect, useState } from "react"; i ...

Switching between all tabs simultaneously in an MDX page (React + Gatsby + MDX) using @reach/tabs

Creating a Tab component for a Gatsby site has proved to be a bit tricky. Imagine having a page with multiple tabs all labeled the same: Heading 1 First tab block Tab 1 | Tab 2 Content Tab 1 Second tab block Tab 1 | Tab 2 Content Tab 1 for the second bl ...

React Alert: It is important for every child within a list to have a distinct "key" prop, not due to a missing key in the map

My current project involves developing a React 18 application. While working on one of the pages, I encountered the following error: https://i.sstatic.net/9Mk2r.png I am aware that this type of error is often linked to the absence of a unique key in the m ...

Showing hierarchical objects retrieved from JSON response

I'm still learning React, so bear with me if this is a simple issue. I have some nested data that I want to show in a list format. The data is fetched and displayed below: data: [ { "id": 1, "domain_url": "localhost", "created_on": "2020-05-26" ...

Using the 'this' keyword in nested functions

I am facing an issue with the following code snippet : <!DOCTYPE html> <html> <head> <title>Drag-Drop tests</title> <meta charset="UTF-8"> </head> <body> <scr ...

Every time I attempt to publish a new page on my website, it doesn't load all at once. Instead, it loads in

Whenever I try to upload a page on my website, it doesn't load properly. Instead of loading all at once, it loads in patches. //$("#idUpcmgMtch").append(nwhtml); //var slyObj = scrlr(); slyObj.reload(); var actid=""; if(pagename="create-team"){$ ...

What is the best way to make a div element take up the entire page

Is there a method to enlarge one div container to cover the entire page, similar to a zoom effect, without displaying any other elements on the page, and then enable the user to return to the normal view by pressing escape or clicking outside of the div ...

Employing JavaScript to set a variable that changes dynamically

In my code, I have a functionality that allows for changing different dropdowns with similar ending IDs. In other parts of the code, I have assigned variables rl and rl_extra as well as rs and rs_extra. Now, when the var prefix is determined to be either ...

Is there a JavaScript toolkit specifically designed for animating mobile devices?

Currently in search of a JavaScript Library that is similar to impress.js, allowing me to create dynamic animations on text content that are compatible with iOS/Android. Although Hype by Tumult seems promising, I am not interested in an editor but rather ...