Shade a selection of rows within the GridPanel Ext.net (ExtJS)

How can we highlight a specific set of rows in an Ext.net gridPanel by changing their color?

Currently, the GridPanel renders using the following function:

 function (value, meta, record, rowIndex,columnIndex,store) 
    {
        color= record.data["ColorValue"];
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = '.cssClass'+rowIndex+' {   background color:'+color+'}';
        document.getElementsByTagName('head')[0].appendChild(style);
        grid.store.getAt(rowIndex).set("mySelected", "cssClass"+rowIndex);
    }

However, this approach highlights all the rows with the same color. A test alert(color); revealed that each row actually has a different color.

Is there a better way to achieve this and highlight only the specific set of rows?

Answer №1

If you want to customize the appearance of rows in a GridView, you can override the getRowClass method.

new Ext.grid.GridPanel({
    [...],
    viewConfig: {
        getRowClass: function(record, index, rowParams, store) { return 'some-class'; }
    }
});

Alternatively, if you prefer to apply colors after the rendering process, you can set a specific class for each row individually:

grid.getView().getRow(0).className += 'some-class';

Please note that these code examples are based on ExtJS 3.4 API, but there may be similar functionality available in version 4.0.

Answer №2

Utilizing ExtJS 4, you have the ability to make use of the highlight function within the row element of the data stored in the grid.

var storage = grid.getStore();
var viewer  = grid.getView();
var item;

storage.each(function(entry) {
    if (entry.get('fieldname') !== 'specified_condition') return;

    //Retrieve the node based on the provided Record, index, or node.
    item = viewer.getNode(entry);
    if (!item) return;

    Ext.get(item).highlight();
});

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

Retrieve events triggered by each element

Currently, my research centers around digital marketing and user experience. In order to gather the necessary data for this study, I must collect event logs from all components within a UI to create datasets on usability patterns. In a web interface, such ...

jQuery's element loading function fails to work with ajax requests

When trying to preload ajax data before attaching it to a div, I utilized the following code: $.ajax({ url: 'ajax.php', data: { modelID:id }, type: 'post', success: function(result){ $(result).load(function(){ ...

Resizing the background while scrolling on a mobile web browser

My website background looks great on desktop, but on mobile (using Chrome) the background starts to resize when I scroll, mainly due to the browser search bar hiding and reappearing upon scroll. Is there a way to prevent my background from resizing? Check ...

finding the index of a particular checkbox in a list

I am working with a list of checkboxes that are dynamically created using JavaScript, each contained within its own separate div element. I need to determine the position number of a specific checkbox within all checkboxes sharing the same class within a p ...

Tips for adjusting the vertical position of an image within a bootstrap column by a small amount

Apologies in advance if this question has already been addressed, and I am struggling to adapt it to my specific scenario. My objective is to adjust the positioning of the two images shown in the screenshot example below so that they align with the grey b ...

Shutting down a filtered v-treeview node becomes sluggish when operating with a large number of items

My v-treeview has a node with approximately 2000 children, and I am in need of applying a filter to it. However, the current issue is that opening the node takes around 3 seconds, while closing it takes about 15 seconds, which is completely unacceptable. ...

Tips for preserving the Context API state when navigating between pages in Next.js

Currently, I am working on a project that involves using nextJs and TypeScript. To manage global states within my application, I have implemented the context API. However, a recurring issue arises each time I navigate between pages - my state re-evaluates ...

Behavior of jQuery resizable when being used on elements can sometimes

A live demonstration showcasing unusual behavior can be found at: If you attempt to resize the window by grabbing the right border and adjusting it horizontally, the vertical alignment goes awry. This issue persists across all open windows accessed throug ...

Refreshing Ads JavaScript and Ad Placements with NextJS Navigation

My NextJS website utilizes a custom JavaScript provided by an ad provider for running ads. The script is typically structured like this: <script type="text/javascript" src="//cdn.adsite.com/static/js/ad.js" ></script> In ad ...

Prevent pushing values to an array in JavaScript by disabling the Array

I am facing a challenge with a sealed object that has an array member, and I want to restrict direct pushes. var myModule = (function () { "use strict"; var a = (function () { var _b = {}, _c = _c = "", _d = []; ...

Exporting Javascript functions is not possible

Programming in TypeScript import { Component, OnInit } from '@angular/core'; import {loadCalendar} from '../../../../scripts/artist/artist-home'; import {activate_searchBar} from '../../../../scripts/search_bar_activate'; @C ...

Reactjs encountered an error: _result2.default.fetchResult is not recognized as a valid function

The following error message is being displayed: https://i.sstatic.net/cS4J5.png Regarding the Class ResultContainer: Although I have attempted to use this.fetchResult = this.fetchResult.bind(this) in the constructor, the error persists without any change ...

Tips for retrieving data from a database with just one key press

There is a text field that triggers a JavaScript function when a key is pressed. <input type="text" class="text" id="txt_sh_vid" onKeyPress="vhc_record()" maxlength="4"> The function takes the input from the text field and searches for a result in t ...

Utilizing PHP variables to dynamically assign names to radio input tags, and then extracting their values using jQuery or JavaScript

I am facing an issue with my PHP file that generates radio buttons based on unique pets ids. The variable $idperro is constantly changing to distinguish the set of radio buttons. My goal is to insert the value inside the p tag. Here's the PHP code sn ...

Enhancing Plotly Graphs with Custom Node Values

Encountering an issue while attempting to assign values to nodes on a plotly graph. Code: <html> <head> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> <style> .graph-container { ...

What is the best way to create a "check all" feature in React using child components?

I have come across a few questions here that somewhat address the issue, select all managed state of controlled checkboxes but none of them provide a solution for rendering a component with a checkbox. What I want is something like this, render: funct ...

Using a vanilla JS object as a prop for a child component

I have created a custom Message class in my application to handle incoming messages, which is defined in message.js. Within message.js, I've implemented two classes: Message and EventEmit. The render function in my Message class requires passing an E ...

Tips on incorporating character frequency counting in a string with JavaScript

I am working on a simple project involving HTML code. <textarea id="text" placeholder="Type text...."></textarea> <a id="button" class="button"></a> <textarea id="result" disabled></textarea> Additionally, I have a blo ...

What's going on with the background color? It doesn't seem

I have incorporated Bootstrap into my html code and I am attempting to modify the background color of a div when the screen resolution changes from large to medium or small. Even though I have added a class, the change does not reflect when adjusting the ...

I am looking to insert an array of a specific type into a Postgres database using Node.js, but I am unsure of the process

query.callfunction('fn_create_mp_product', parameters, (err, result) => { if (err) { console.log(err) callback(err); } else { if (result.status == 'success') { callb ...