Home > Backend Development > PHP Tutorial > How to Highlight jqGrid Rows Based on Checkbox Selection?

How to Highlight jqGrid Rows Based on Checkbox Selection?

Linda Hamilton
Release: 2024-12-14 07:31:10
Original
875 people have browsed it

How to Highlight jqGrid Rows Based on Checkbox Selection?

Highlighting Rows Based on Checkbox Status in jqGrid

When working with jqGrid, you may encounter a scenario where you want to highlight rows based on the state of a checkbox. This feature can provide a clear and visual representation of selected rows.

Implementation:

jQuery UI ThemeRoller

A simpler approach is to utilize the jQuery UI ThemeRoller to style your checkbox cell. This method involves customizing the appearance of the cell based on the checked state. You can achieve this by adding the following CSS to your code:

.ui-jqgrid .ui-sgfcb .ui-state-checked {
  background-color: #ffff99;
}
Copy after login

Custom Styling

If you prefer a more tailored approach, you can implement your own styling using the rowattr callback. This callback allows you to define custom attributes for each grid row, enabling you to dynamically modify the row's appearance based on the checkbox value. A sample implementation would be:

rowattr: function (rd) {
  if (rd.GroupHeader === "1") {
    return {"class": "highlighted-row"};
  }
}
Copy after login

In this case, the highlighted-row class would contain your custom styling for the highlighted rows.

Other Considerations:

  • Ensure that the checkbox column is not sortable to prevent unexpected behavior when sorting.
  • Consider using cellclasses to further customize the appearance of individual cells based on their data.
  • The highlighted cells will be visually noticeable, enhancing the user experience when navigating the grid.

The above is the detailed content of How to Highlight jqGrid Rows Based on Checkbox Selection?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template