sort rows in the aui table using selectable options

I'm currently using the aui library to create a sortable datatable. I want the cells to be selectable without any javascript event binding.

Here is how my columns are defined:

var columns = [
    {
        key: "col1",
        label: "Column 1",
        sortable: true
    },
    {
        key: "col2",
        label: "Column 2",
        sortable: true
    },
    ...
];

When I initialize the datatable with:

var myDatatable = new A.DataTable.Base({
    columnset : columns,
    recordset : data
});

I can select rows individually but sorting doesn't work.

However, if I use:

var myDatatable = new A.DataTable({
    columnset : columns,
    recordset : data
});

The table becomes sortable but I lose the ability to select the data by simply clicking and dragging the mouse.

I've tried adding these plugins:

plugins: [{
    cfg: {
        type: "rows"
    },
    fn: A.Plugin.DataTableHighlight
},
{
    cfg: {
        selectRow: true,
        selectColumn: true
    },
    fn: A.Plugin.DataTableSelection
}]

However, I still can't achieve a plain simple selection. You can check the aui documentation here. The basic example covers most of my needs except for sorting, and in the real-world example, double-clicking (for editing) is required to select/copy the cell contents.

Please assist. Thank you!

Answer №1

By eliminating the mousedown and mouseup events and modifying the getEditor function, I was able to successfully solve the issue with rendering the table while maintaining the functionality of sorting.

/* Ensure text is not selectable */
myDatatable.get("contentBox").purge(true, "mousedown");
myDatatable.get("contentBox").purge(true, "mouseup");
/* Override getEditor method */
A.DataTable.prototype.getEditor = function() {};

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

Maximize efficiency in JavaScript sorting algorithms that heavily rely on the

Recently, I developed a HTML viewer resembling a mail program interface (though without actual emails, just user messages). The layout mimics Windows Explorer with labels at the top and messages that can be sorted by date or alphabetically. Here's an ...

Connecting script.js with html file

I am attempting to connect the script.js file to my HTML in order to incorporate interactive features on the page. The goal was to change the image of door1 when it is clicked on, but it doesn't seem to be working. Any feedback on this issue would be ...

Exclude the file and directory patterns from being watched with PM2: ignore folder

I need help with configuring pm2 to stop monitoring folders that have names like cache or tmp. I've tried multiple approaches in my app.json configuration file: {"apps": [{ "name": "BSTAT", "script": &q ...

Struggling to effectively use XPath to target LI elements that contain specific text

Below is the HTML code for the list item in question: <li class="disabled-result" data-option-array-index="1" style="">4" (0)</li> Here is my attempt at using JavaScript to hide this list item, but it's not working as expected: var xpat ...

What is the best method for accessing the service response data when I am sending back an array of custom map with a promise as an object?

Sharing my code snippet below: function createObject(title, array){ this.title = title; this.array = array; } //$scope.objects is an array of objects function mapPromise(title, promise){ this.title= title; this.promise = promise; }; var fet ...

How about we display the Extents Algorithm?

Oh wise and knowledgeable coding community, I come seeking your expertise... I am working with the three.js library and facing a challenge in implementing a 'show extents' button. This button should adjust the camera position so that all objects ...

"Utilize Ember Data to extract data using a specific serializer

I'm working with an object called "Residence" that consists of various details. I am trying to use the serializer "extractSingle" to establish its relationships when receiving data from the server, but I keep encountering the error message "Unable to ...

What is the quickest way to increase value in the DOM?

Is there a more efficient method for incrementing a DOM value that you know of? let progress = +document.getElementById("progress").innerHTML; progress++; document.getElementById("progress").innerHTML = progress; Perhaps something like t ...

The light/dark mode toggle is a one-time use feature

I've been experimenting with creating a button to toggle between light and dark modes on my website. Initially, it's set to light mode, but when I try switching to dark mode, it works fine. However, the issue arises when attempting to switch back ...

Simple getJSON inquiry - why does the second parameter frequently go unnoticed?

I'm brand new to the world of Javascript, Jquery, and all that comes with it. I've been diving into trying to wrap my head around the getJSON function -- according to the documentation, it states: jQuery.getJSON( url [, data ] [, success ] ) ...

What is the correct method for decreasing the width of tab labels in Angular Material?

Addressing the Issue Given that /deep/, >>>, and ::ng-deep are no longer recommended, what is the appropriate approach to reduce the width of mat-tab-label which has a minimum width of 160px on desktop devices? Is there a way to achieve this wit ...

Define the data type for the variable Node.childNodes in TypeScript

I have encountered a dilemma in my code: const myElem: HTMLElement | null = document.getElementById("asd"); let arrow: any = []; if (myElem) { arrow = myElem.childNodes; arrow[1].style.display = "none"; arrow[2].style.display = & ...

Ensuring that non-English characters are accepted in jQuery validation using regular expressions

I have a validator for checking website URLs on my site, and it works perfectly fine. However, I now need to enable the input of non-English characters like Arabic. I have some knowledge about regular expressions, but I am unsure about how to allow Arabic ...

Failing to include a valid string in the path will result in an

Within my node API, I have a function that updates the email address array for either a contact or a farm. The concept is the same, but the difference lies in where the array is located: in farms it's within Records.emails, and in Contacts it's s ...

Value becomes null when updating in Node.js

I've been working on updating a value through API calls in express and node js. Here is how my route is set up: var express = require('express'); var router = express.Router(); router.put('/updateValue/:id', function(req, res, ne ...

Transforming text colors dynamically using Vue.js

Here is an Angular code snippet: <div [style.color]="'#' + prod.id.substring(0,6)"> <small>{{ prod.id }}</small> </div> Now I want to create a similar code using vue.js. ...

Encountering an error with my electron application built using create-react-app

While I'm working on my project, my electron window is showing this error message. TypeError: fs.existsSync is not a function getElectronPath ../node_modules/electron/index.js:7 4 | var pathFile = path.join(__dirname, 'path.txt') 5 | ...

Struggle arising from the clash between a customized image service and the built-in image element

Dealing with a custom Angular service called Image, I realized that using this name poses a problem as it clashes with Javascript's native Image element constructor, also named Image. This conflict arises when attempting to utilize both the custom Im ...

conceal the "load more" option when no additional content is available for loading

I recently incorporated a "load more" button using the plugin called "easy load more" (https://wordpress.org/plugins/easy-load-more/). While the button is functioning well, it continues to appear even when there are no more posts to display. I am seeking s ...

Pace.js doesn't bother waiting for iframes to completely load before moving on

On my website, I am using pace.js but encountering issues with pages containing iframes. Is there a method to ensure that pace.js considers the content loading within those iframes? I attempted to configure paceOptions to wait for the iframe selector to l ...