How can I retrieve data during a double-click event in Kendo Grid using Angular?

How can I retrieve data on the doubleClick event in a Kendo Grid?

I want to access the same object that is fetched during the selected event, which would be the dataitem at the selected index row.

HTML:

<kendo-grid
    #myGrid
    [data]="gridData"
    [selectable]="true"
    (selectionChange)="onSelection($event)"
    (dblclick)="doubleClickHandler(myGrid, $event)">
</kendo-grid>

TypeScript:

onSelection(event){
   // Retrieve dataItem from selected row
   event.selectedRows[0].dataItem
}

doubleClickHandler(grid, event){

// Obtain dataItem similar to the onSelection function

}

Example of dataItem object: [{ "id":0, "name":"Chai", "category": "Beverages", "price": "18", "instock": "39"

}] https://i.stack.imgur.com/wR6Sf.png thanks,

Federico

Answer №1

To effectively handle the SelectionChange event, one approach is to extract the dataItem from the selected row and save it in a private variable. Then, when dealing with the double-click event, you can simply access the value stored in the private variable.

Example: https://stackblitz.com/edit/angular-n4cn9w-phvv6a?file=app%2Fapp.component.ts


2024-03-13 Update

A scenario was presented where the double-click solution may not function as intended. If a row is selected and a double-click occurs anywhere on the grid (even in the header/footer), the code within the onGridDoubleClicked event will still be triggered. This issue presents challenges for resolution.

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

Using the useRef hook to target a particular input element for focus among a group of multiple inputs

I'm currently working with React and facing an issue where the child components lose focus on input fields every time they are re-rendered within the parent component. I update some state when the input is changed, but the focus is lost in the process ...

Troubleshooting CORS errors in axios requests within a Next.js application

Encountering an issue while attempting to make an axios call to my API on a different localhost. How can this be resolved? The tech stack being used includes Next.js, TypeScript, and Axios. Below is the function which - although written poorly for testing ...

identifiers that have been duplicated errors

My journey with VS 2017 and angular 2 started off smoothly, but I hit a roadblock when I encountered 352 errors upon restarting my machine. The errors were mostly "Duplicate Identifier errors," and after some investigation, I realized that I had the file i ...

Implementing Twitter Login with Vue, Vuex, and Firebase

Exploring a Twitter login option for my sports social media dashboard project, I followed a helpful tutorial. While I've successfully implemented the HelloWorld component and retained the app.vue and main.js components, I encountered an error stating ...

Combining the powers of $.get and $.ready

Basically, I am facing an issue with my ajax call where sometimes it completes before the page is fully loaded. I attempted to use $( fn ) to wrap the callback function, but unfortunately, the callback does not trigger if the page is already loaded. Does a ...

Automatically redirect to the linked page once the video concludes

Would it be feasible for a html5 video to trigger the opening of a new page upon completion? What would be the approach to achieve this using javascript? ...

Using PersistedModel.create(Array) will generate an object containing properties that are numbered sequentially

Here is a piece of code that makes a call to a Loopback API method with an array of values. The input data is correct, no errors are thrown by the API, and the subscribe block executes as expected. const newStudentGroups = selectedStudentI ...

Jest is unable to handle ESM local imports during resolution

I am encountering an issue with my Typescript project that contains two files, a.ts and b.ts. In a.ts, I have imported b.ts using the following syntax: import * from "./b.js" While this setup works smoothly with Typescript, Jest (using ts-jest) ...

Using Angular 5 to make a series of API calls, fetching a large object while also updating the UI with progress

I'm currently working on an Angular 5 Project where speed and responsiveness are crucial when retrieving a large object from the server. To optimize performance, I have broken down the object (resembling a Word Document) into main components (similar ...

Creating a function in Ionic 2: A step-by-step guide

I'm having trouble defining a simple function in Ionic 2. Here is the code I am struggling with: import { Component } from '@angular/core'; import { NavController, NavParams } from 'ionic-angular'; @Component({ selector: &a ...

What is the best way to define a function in React hooks - using a function statement or

When working with a react hook and needing to define a function inside it, which approach is preferable? useEffect(() => { //... function handler() {} //... }, []); or should I use the newer const declaration instead? useEffect(() => { ...

Clicking on "li" to activate and deactivate

Currently utilizing: $('#btnEmpresarial').attr('onclick','').unbind('click'); In order to deactivate a read using javascript.. However, I now require enabling the onclick after the function has completed. Is ther ...

The entire space should be filled with the background

My goal is to achieve the following while addressing some current issues: The background is currently limited to affecting only the container. I want it to span the entire area. There needs to be space between the cards and padding inside them. https://i ...

Is it possible to export an imported merged namespace in Typescript?

Within my library, I have a collection of merged declarations setup like this: export class Foo {...} export namespace Foo { export class Bar {...} ... } export default Foo These merged declarations often contain inner classes and specific errors r ...

When using `npm publish`, any files located within the `node_modules

After developing an npm package, I included some modules in the node_modules directory to make them accessible as "modules". For instance, I have a module called my-module.js in node_modules which I require in my code using require('my-module'). ...

React-Troubleshooting list items and keys: A comprehensive guide to resolving common issues

I'm facing a challenge with generating unique key ID's for my list items. Even though I thought I had a good understanding of how unique keys function, it seems that I am mistaken. In the code snippet below, using key={index} or key={item} is no ...

Is it possible to do bulk deletion in Flask Restless using AngularJS or JavaScript?

I am trying to implement bulk delete functionality in my AngularJS application by making an HTTP request to a Flask Restless API with version 0.17.0. While I know how to delete records one by one using their IDs in the URL, I am unsure if it is possible to ...

Issue encountered when attempting to assign an action() to each individual component

I'm facing an issue with the button component I've created. import { Component, OnInit, Input } from '@angular/core'; @Component({ selector: 'app-button', template: ` <ion-button color="{{color}}" (click)="action()"&g ...

Adding an onload event in a function-based component without using a fetch call

Looking at the code snippet below for a React component: import React from "react"; import { Carousel } from "react-bootstrap"; function CarouselHome() { return ( <> ...

How can I detect a change in user input using jQuery?

When utilizing jquery .oninput with an element, the event will trigger instantly whenever there is a change in the input value. In my scenario, it is necessary for me to validate the input value by calling the service immediately after any changes occur. ...