How to Get the Clicked Cell Details in JavaScript Grid?
This article explains how to get the clicked cell details in JavaScript Grid. You can get the clicked grid cell details by passing the target element to the “getRowInfo” method of the Grid component.
This is explained in the following sample code, in which the “click” event has been bound to the Grid element, and clicked cell details are retrieved by using the “getRowInfo” method. The cell value is displayed in an alert popup.
TS
let grid: Grid = new Grid({ dataSource: data, columns: [ { field: "OrderID", headerText: "Order ID", width: 120, textAlign: "Right" }, { field: "CustomerName", headerText: "Customer Name", width: 150 }, { field: "Freight", width: 120, format: "C2", textAlign: "Right" }, { field: "ShipCountry", headerText: "Ship Country", width: 150 } ] }); grid.appendTo("#Grid"); document.getElementById("Grid").addEventListener("click", function(args) { if ((args.target as any).classList.contains("e-rowcell")) { let rowInfo = grid.getRowInfo(args.target); // Get row information alert(rowInfo.rowData[rowInfo.column["field"]]); } });
You can also refer:
Typescript Sample: Typescript Demo
Angular Sample: Angular Demo
React Sample: React Demo
Conclusion
We hope you enjoyed learning about how to get the clicked cell details in the JavaScript Grid.
You can refer to our JavaScript Grid feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript Grid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums,
BoldDesk Support, or feedback portal. We are always happy to assist you!