We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to select or highlight rows based on data?

Solution

You can select or highlight rows based on data using the queryCellInfo event or can also select a row using an external button click event.

The queryCellInfo is triggered every time a request is made to access particular cell information, element and data.

In the argument of the queryCellInfo event, you can obtain the following details.

Name

Description

cell

Returns Grid cell

cancel

Returns the cancel option value

data

Returns current row record object

text

Returns the text value in the cell

column

Returns the column object

foreignkeydata

Returns the foreignkey record object

model

Returns the grid model

type

Returns the name of the event

 

By comparing the value obtained from the argument of the queryCellInfo event, you can select the corresponding data rows using the selectRows() method of the Grid.

Example:

In the following example, the records based on the field EmployeeID are highlighted/selected.

  1. Render the Grid.

JS

 

MVC

 

ASP.NET

  1. In the queryCellInfo event, custom Css to the rows with EmployeeID greaterThan 3 and lessThan 6 is applied.

JS

  1. In order to select the rows based on the value/data in the Grid, you can use the selectRows method and pass the index of the row as argument.

JS

  1. In order to select the rows based on a data externally using a button, you can use the selectRows method within the click event of the button.

JS

 

Figure 1: Select/ highlight rows based on the data on row/grid

 

Figure 2: Select rows dynamically based on data on row/grid

Article ID: Published Date: Last Revised Date: Platform: Control:
2979 11/28/2014 08/06/2015 JavaScript ejGrid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.