Tips for altering the background color of a cell in the ui-grid when the value has been changed and is different from the original value (marked as dirty)

After referencing this resource, I successfully implemented a color change feature. However, the solution provided applies the color to the entire row, which is not the desired outcome for me.

I am specifically looking to change the color of only the edited cell. If anyone has any ideas on how to achieve this, please share. Thank you.

Answer №1

Check out this plunker demo showcasing the behavior you're looking for: http://plnkr.co/edit/ZfeiNxiGLqeivFeaqY2y?p=preview

The key section of code is displayed below:

gridApi.edit.on.afterCellEdit($scope, function(rowEntity, colDef, newValue, oldValue) {

colDef.cellClass = function(grid, row, col, rowRenderIndex, colRenderIndex) {
      if (rowEntity.id === row.entity.id && newValue !== oldValue) {
        return "test";
      }
      return "";
    };

$scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);

Keep in mind that "test" is the class name specified in main.css

.test {
 background-color: red !important;
}

UPDATE: I've created a variation of your plunker example here: http://plnkr.co/edit/OgecJQo8FOREIsQcufuz?p=preview

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

Adjust the form action and text input name according to the selected radio input

Seeking assistance with the following code, can someone help? $(document).ready(function() { $('#searchform').submit(function() { var action = ''; if($('.action_url').val() == 'l_catalog') { ...

What are the reasons for the slower runtime of node.js compared to the Google Chrome console

It's interesting to note that both Chrome and node.js operate on the same V8 javascript engine. Here is my take on it: Chrome, despite running internal executions, also handles additional UI tasks which could potentially slow it down On the other ha ...

Step-by-step guide to configuring preact-render-to-string with Express

Could someone guide me through setting up preact-render-to-string with express? Detailed instructions are here Installation for express can be found here I've gone through the provided links, but I'm unfamiliar with using node. I'm struggl ...

What could be the reason why both the add and remove functions are unable to work simultaneously within a JavaScript function?

Hi there! I recently started diving into JavaScript and encountered a little hiccup. I've been working on a dice game where images change randomly whenever a button is clicked. The images transition from one to another, but I wanted to add a rolling ...

Mysterious failure of JavaScript regular expression when encountering the term "tennis"

We developed a JavaScript script to detect duplicates or potential duplicates, but it seems to have some issues with certain words like "tennis." The script functions correctly in most cases, but fails when analyzing phrases related to the word "tennis" fo ...

Symfony's DataTables is encountering an issue with the JSON response, showing

I have encountered an issue while trying to fetch data from a response within my template table (using DataTables). The error message I receive is as follows: DataTables warning: table id=example - Invalid JSON response. For more information about this ...

Why do we even need Angular controllers when directives can perform the same tasks as controllers?

As a new Angular developer, I have to say that I am really impressed with the architecture of this framework. However, one thing that puzzles me is the existence of controllers. Let me elaborate: Services in Angular seem to have a clear purpose: 1) Store ...

Confirm that step attribute is applied to input of number type

When working with the following HTML code, I encounter a challenge with validating the step: <form name="myForm"> <input type="number" name="test" min={{min}} max={{max}} step={{step}}> <div class="error-popup" ng-if="myForm.test.$touched & ...

Ways to verify if an email has been viewed through the client-side perspective

How can I determine if an email has been read on the client side using PHP? I need to verify if emails sent by me have been opened by recipients on their end. Additionally, I would like to extract the following details from the client's machine: 1. ...

Controlling Node.js application with Electron app: initiating and terminating

I'm currently working on the functionality to control the start and stop of another node.js application within my electron app. So far, I've managed to successfully start the node application from bot.js by running npm start to launch the electr ...

Specialized spinning tool not in sight

Having an angular 11 application with a spinner that should be visible during data loading from the backend. However, when the fa-icon is pressed by the user, it becomes invisible while waiting for the server response. The issue arises when the spinner its ...

Looking for a way to deactivate the loader after the submission is complete

Seeking to implement a loader on my asp.net webforms app. Here's my javascript loader: function loading() { $("#loading").show(); } function loaded() { $("#loading").hide(); } html loader ...

Exploring Password Verification Techniques in JavaScript

I'm struggling with a password comparison issue in JavaScript. It was working fine on my previous project, but for some reason it's not working now. Here is the HTML code: <form> <label> <strong>Username</ ...

Design a button for removing the selected value in select2

Can anyone provide some guidance on using select2? I am working with 2 select2 elements, and I want the selected value to be displayed on a button instead of in the input area of the select2. This way, the select2 will still display the placeholder text. ...

Having trouble identifying the issue with the dependent select drop down in my Active Admin setup (Rails 3.2, Active Admin 1.0)

I am currently working on developing a Ruby on Rails application that involves three models: Games that can be categorized into a Sector (referred to as GameSector) and a subsector (known as GameSubsector) A sector consists of multiple subsectors. A Subs ...

Guide on transferring files between Node.js/Express servers from receiving files at Server A to sending files to Server B

Currently, I'm tackling node.js express servers and I've hit a roadblock! Despite my efforts to scour the documentation and other resources, I can't seem to find the right solution. Here's what I need to accomplish: Receive 2-3 PDF ...

Update the table contents smoothly using the html helper PagedListPager without having to reload the entire

I am struggling with a specific line of code that utilizes the html helper's PagedListPager: @Html.PagedListPager(Model.kyc_paged_list, page => Url.Action("ClientDetails", new { id = ViewBag.ID, kyc_page = page, transaction_page = Model. ...

Interference in the output of .innerHTML leads to disruption

I have been working on a feature to display a calculated price based on the selected quantity for each individual product. I attempted to duplicate the code and modify variable names, but encountered issues with the increase/decrease buttons triggering mul ...

Enhance communication system by optimizing MySQL, JavaScript, and PHP chat functionality

I have created a chat application using Javascript, PHP, and MySQL for two users. Every 3 seconds, it makes an AJAX request to a PHP file to retrieve messages from the database and update the page. Currently, the PHP query used is: SELECT * FROM tmessages ...

Issue: [ng:areq] The parameter 'PieController' is not properly defined, it is currently undefined

Why am I getting an error when using ng-controller='DoughnutCtrl' in a dive? Error: [ng:areq] Argument 'DoughnutCtrl' is not a function, got undefined Here is my Chart.js code: 'use strict'; angular.module('portfoli ...