Category / Section
How to select the specific record in the grid using its primary key value
2 mins read
You can get the row index value for a particular record in a grid and select it with the help of its primary key value. This can be achieved by passing the required primary key value to the getRowIndexByPrimaryKey method which that returns the index value of the row. With the help of this row index value the particular record can be selected by using the selectRow method.
This is demonstrated explained in the below following code snippet and sample on button click event.
<script> // Get the row index and select record on button click button.element.onclick = () => { // Get the row index value using its primary key var index = grid.getRowIndexByPrimaryKey(10251); // Select the row using the index value grid.selectRow(index) }; </script>
Output
You can find the samples here:
JavaScript (ES5) Sample: https://stackblitz.com/edit/jqmn1z
TypeScript Sample: https://stackblitz.com/edit/bae3vz-rzsk56