Is there a way to prevent the entire row from being selected when a radio button is clicked in an md-data

Can anyone assist me with an issue I am having with my data table? When I select a radio button, the entire table row is getting selected instead of just the radio button. Below is the code snippet:

https://i.sstatic.net/dicwF.png

My Expectation:

When clicking on a radio button, only the button should be selected and not the entire table row. Demo Any help or insights on this issue would be greatly appreciated.

  <md-data-table-container>
               <table md-data-table md-row-select="testConfig.selected">
                  <thead md-trim-column-names md-order="testConfig.order">
                     <tr>
                        <th order-by="name">Report Name</th>
                        <th numeric order-by="views.value">Visits</th>
                        <th numeric order-by="users.value">Unique Users</th>
                        <th>Users</th>
                     </tr>
                  </thead>
                  <tbody md-auto-select>
                     <tr ng-repeat="report in test_data | orderBy: testConfig.order">
                        <td>{{report.name}}</td>
                        <td>{{report.views.value}}</td>
                        <td>{{report.users.value}}</td>
                        <td>
                           <ul>
                              <li ng-repeat="person in people">
                                 <label>
                                 <input type="radio" ng-model="$parent.name" name="name" value="{{person.name}}" required />{{person.name}}
                                 </label>
                              </li>
                           </ul>
                        </td>
                     </tr>
                  </tbody>
               </table>
            </md-data-table-container>

Answer №1

To avoid the click event from propagating to the table row, apply Event.stopPropagation on the label of the radio button:

<md-data-table-container>
   <table md-data-table md-row-select="testConfig.selected">
      <thead md-trim-column-names md-order="testConfig.order">
         <tr>
            <th order-by="name">Report Name</th>
            <th numeric order-by="views.value">Visits</th>
            <th numeric order-by="users.value">Unique Users</th>
            <th>Users</th>
         </tr>
      </thead>
      <tbody md-auto-select>
         <tr ng-repeat="report in test_data | orderBy: testConfig.order">
            <td>{{report.name}}</td>
            <td>{{report.views.value}}</td>
            <td>{{report.users.value}}</td>
            <td>
               <ul>
                  <li ng-repeat="person in people">
                     <label ng-click="$event.stopPropagation()">
                     <input type="radio" ng-model="$parent.name" name="name" value="{{person.name}}" required />{{person.name}}
                     </label>
                  </li>
               </ul>
            </td>
         </tr>
      </tbody>
   </table>
</md-data-table-container>

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

What steps should I follow to utilize a JavaScript dependency following an NPM installation?

After successfully installing Fuse.js using npm, I am having trouble using the dependency in my JavaScript code. The website instructions suggest adding the following code to make it work: var books = [{ 'ISBN': 'A', 'title&ap ...

Using jQuery's .each() method to iterate over a JSON object may only display the

Running into some trouble with jQuery.each(). I'm pulling JSON data from another PHP file and trying to display a specific key value from it. This is the JavaScript code I have: <div class="row" id="fetchmember"> <script type="text/javasc ...

The method of utilizing React with Redux to display component properties

I am currently trying to include my common component in my main.js file Successfully implemented this However, when attempting to print my Redux data values in the common component, I created a method called handleClickForRedux to handle this task. Even af ...

Struggling with properly navigating a JSON file in my JavaScript code... specifically trying to access and retrieve the "responseObject.weather[i].weatherresponseObject.weather[i].description" data

Struggling with extracting data from a PHP file in JSON format to display on an HTML file using JavaScript. I seem to be encountering issues with accessing responseObject.weather[i].weatherresponseObject.weather[i].description, and I suspect it might be d ...

Remove the color options from the Material UI theme

Can certain color types be excluded from the MUI palette in MUI v5? For example, can background and error colors be removed, allowing only colors defined in a custom theme file to be used? I attempted using 'never' but it did not provide a solut ...

What could be the reason for this Javascript code not functioning as intended, failing to generate a random number between 1 and 3 when I click on any of the buttons

Could someone help me with generating a random number between 1 and 3 each time I click on one of the buttons (rock, paper, scissors)? I am new to programming and not sure what I'm doing wrong. <!doctype html> <html lang="en"> <head& ...

CKFinder Error: Unable to find definition for t.event.special.swipe

Upon using CKFinder 3.2.0 with Firefox 44.0, I encountered the following error message. Interestingly, this issue is exclusive to Firefox while Chrome works perfectly fine. Any insights on what could be causing this problem and how it can be resolved? Ty ...

Azure Chatbot that logs conversations in Webchat whenever the user selects 'none of the above' option

Recently, I've delved into the world of web chat services and embarked on a journey to craft a chat bot using pure JavaScript code that can seamlessly integrate into any HTML file. Despite consulting Microsoft's documentation, I find myself in a ...

JavaScript Class vs Function as Definition

Having trouble locating documentation for this issue. I devised a JavaScript class in the following manner: class Polygon { constructor(height, width) { this.height = height; this.width = width; } area = function() { return this.height ...

Utilizing a Meteor Method within a Promise Handler [Halting without Throwing an Error]

I've been working on integrating the Gumroad-API NPM package into my Meteor app, but I've run into some server-side issues. Specifically, when attempting to make a Meteor method call or insert data into a collection within a Promise callback. Be ...

Is there a method to access the variable name of v-model from a child component in the parent component?

In the scenario below, I am customizing a vue radio component and using the model option to retrieve the v-model value, which is expected to be a string '1'. Is there a way for me to access its variable name 'radio1' in the child compon ...

Error in React-router: Unable to assign value to the 'props' property as it is undefined

Currently, I am working on setting up routing with Meteor using the react-router package. However, I have encountered a specific TypeError: Here is a link to an image that provides more context: This is the code snippet from my main.js file: import Reac ...

Vue js is throwing an error because it is unable to find the "buscador" property or method that is being referenced in the render function

I am currently diving into the world of laravel combined with Vue js. I am working on integrating a search engine using vue js components, and I would greatly appreciate any help you can provide. Thank you in advance. Below is the Vue js component where t ...

Have you ever wondered why req.body returns as undefined when using body parser?

Every time I attempt to make a post request, I keep receiving an error message stating that req.body is returning as undefined. Below is the content of my server.js file: import express from 'express'; import bodyParser from 'body-parser&ap ...

Modules are being installed to the application's root directory using NPM

I made a mistake and have tried everything to correct it, but no success. Every time I run 'npm install' on a new node project, it installs all dependencies in the root of the application instead of the expected /node_modules/ directory. For ex ...

Enhance CKEditor with Linked Select Boxes Plugin

I have ventured into writing a CKEditor Plugin and have grasped the basic concepts. For instance: CKEDITOR.dialog.add( 'addDocumentGroupDialog', function ( editor ) { return { title: 'Link to a document group', min ...

Tips for combining a select option and search field into a seamless integrated feature

I'm looking to implement a search field in my project that includes the ability to select specific parameters before running the search. I want it to have a seamless design similar to the image shown below. https://i.sstatic.net/niWP8.png Although I ...

ion-select is experiencing display issues

I've been attempting to incorporate select options from the ionic framework, following the guidelines found here: http://ionicframework.com/docs/v2/api/components/select/Select/ <ion-item> <ion-label>Toppings</ion-label> <ion ...

Show or hide text when list item is clicked

This is the rundown of services <div> <a href="#hig"><button class="tag-btn">High blood pressure Diabetes</button></a> <a href="#hih"><button class="tag-btn">High ch ...

Web server experiencing issues with loading scripts and CSS files

After successfully building my project using CodeIgniter on localhost, I encountered an issue when trying to run it on a webhost. The site was functional but the design elements such as scripts and stylesheets were not loading properly. Before uploading t ...