Prevent row selection in jqGrid when right-clicking

Currently in jqGrid, I have disabled row selection using the following code:

beforeSelectRow: function() {
     return false;
}

This setup works perfectly for left clicking. However, I've noticed that the beforeSelectRow event handler isn't being triggered when right-clicking, and the row is still selected. This poses an issue for me as I'm creating a custom context menu.

To address this, I found a workaround which some may consider a hack, outlined in this answer on Stack Overflow: Is it possible to Stop jqGrid row(s) from being selected and/or highlighted?

I'm curious if there's a more elegant solution to achieve the same result without resorting to hacks?

Thank you!

Update

It seems that this issue only arises with subgrids. A demonstration can be seen in this example. If you test it out, you'll observe that left clicking does not select the row, but right clicking does.

(I must admit, I took the easy road and borrowed this example from another question answered by Oleg.)

Answer №1

In order to deactivate the row selection feature, you can set up the onSelectRow function to return false. This will prevent both left and right-click actions.

onSelectRow: function() {
     return false;
}

If you wish to deselect a row when right-clicked:

onRightClickRow: function () {
    grid.jqGrid('resetSelection');
    return false;
}

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

Show or hide specific elements based on parameters using ng-show in Angular

One challenge I am facing is how to manage a menu with multiple buttons that open submenus without using a massive switch statement in my code. Instead, I want to try something different: In the HTML file, I call the function toggleVis and pass the nam ...

Show a Toast in React without relying on useEffect to manage the state

I have successfully implemented the Toast functionality from react-bootstrap into my application using the provided code. However, I am unsure if it is necessary to utilize useEffect to set show with setShow(items.length > 0);. Would it be simpler to ...

Having difficulty adding multiple items to the state array

I am currently working on a parent component that iterates over an array and passes props to a child component. In the child component (shown below), I have checkboxes with Font Awesome icons for users to mark their selections. When a user checks a box, I ...

Utilizing color schemes in your design: a step-by-step guide

Is there a way to utilize the custom color scheme defined in the theme export default createMuiTheme({ palette: { primary: { main: 'red', contrastText: '#ffffff' }, secondary: { main: 'green', ...

ES6 syntax specification allows for the use of a fat arrow function for declaring React components

When learning React, I have noticed two different ways of declaring components. The first is using the classic fat arrow syntax with a return statement. const Component = () => { return ( <div>Hello</div> ) } Recently, I came ...

SecurityError: The dubious operation triggers CORS to persist in its insecurities

I have developed an HTTP server using Express in Node.js. This server is currently running locally on port 3000. There is a served HTML page called "index.html" which makes AJAX GET requests for contents (in HTML format). These AJAX contents are also serv ...

What is the best way to transfer text from a textbox to the clipboard with the help of jquery, javascript

Looking to add a copy to clipboard button on your website but want to avoid using Flash? Search for methods that don't require the outdated technology. Is there a way to achieve this without relying on Flash? ...

Run JavaScript code before finalizing the "submit" action within a Ruby on Rails application

Having trouble with utilizing old JS scripts found on Stack Overflow. <div class="form-actions"> <%= f.button :submit, class:"btn btn-success create-campaign" %> </div> The submit button is causing an issue for me. <div clas ...

Express 4.14.1 experiencing issues with URL rewriting

I have come across several Stack Overflow posts suggesting that to rewrite a URL in Express 4, one would need to implement something similar to the code below: router.use('/one/:someId', (req, res, next) => { req.url = `/two/${req.params. ...

Error message: Invalid input for directive, only numeric values are accepted

I need help with a directive that restricts non-numeric symbols in an input field. Below is the code for the directive: import { NgControl } from "@angular/forms"; import { HostListener, Directive } from "@angular/core"; @Direct ...

Combining Arrays in Vue: A Guide on Merging Two Arrays from the Same Object

My current task involves retrieving data from an API that provides me with a collection of items. Each item consists of a string labeled correct_answer and an array named incorrect_answers. I am in the process of merging these values within each item so t ...

Passing object values between functions in JavaScript: a comprehensive guide

In my code, I use lines like the one below to retrieve data from an intranet website: util.setProp(obj, "firstNameOld", $(msg).find('#fname_a').text()); Now, in the same file, I have another function where I need to use the value stored in the ...

Analyzing database entries containing unique identifiers and formatted with Bootstrap styles

Struggling with properly applying quotation marks around IDs and Bootstrap formatting. The HTML snippet should resemble this: <tr> <th scope="row">1</th> <td>HOU</td><td>-9.8</td> <td id="odds-1">2</td&g ...

Distinguishing Hex Colors in Threejs

While working on my material, I decided to use the hex code 0x205081 like this: material = new THREE.MeshBasicMaterial({color: 0x205081, vertexColors: THREE.FaceColors}); However, when I attempt to revert a few colors back to the original shade (0x205081 ...

Utilizing jQuery Extensions with Greasemonkey (e.g. tooltips)

I have been experimenting with the tipsy jQuery plugin in my greasemonkey script, and for the most part, it's going well. I am utilizing the @require meta tag to bring in the jquery and tipsy js files, but there are a few challenges that I need to add ...

What is causing the initial $.ajax call to fail when sending a data object?

I'm facing an issue with the first $.ajax() call. I need to include URL parameters in the ajax data property. To see this problem in action, check out this fiddle: http://jsfiddle.net/f9e5Y/ Below is the JavaScript code: var urlParameters = { pag ...

There was an error code -32700 encountered while attempting to post form data to the jsonrpc endpoint

As I work on creating a billing form to send data to a jsonrpc endpoint, I encounter an issue. Despite receiving a status code of 200 from the server, the response I get is: {message: "Parse error. Invalid JSON was received by the server.", code: -32700,.. ...

Unable to perform surveillance on the htpp.get method

Example snippet: if (!this.scope.popupHtmlTemplate) { this.$http.get("widgets/pinpointcomponent/browseLibraries/resources/browseLibrariesDialogModal.html") .success((data: any) => { console.log("Processing success"+data) if (dat ...

Trouble with JavaScript loading in HTML webpage

<!DOCTYPE html> <html> <head> <title>Breakout Game</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <canvas width="900" height="450" class="canvas"></canvas> ...

Warning in Vue 3: Production is being disrupted by "tags with side effects"

After recently upgrading from Vue 2 to Vue 3, I encountered a problem in my app where certain parts show a warning in development mode: [Vue warn]: Template compilation error: Tags with side effect (<script> and <style>) are ignored in client ...