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 change a row's background-color or color comparing pieces of information

Thread ID:

Created:

Updated:

Platform:

Replies:

130096 Apr 21,2017 03:54 AM Apr 24,2017 02:45 AM JavaScript 1
loading
Tags: ejGrid
Daniel Pujante
Asked On April 21, 2017 03:54 AM

Hi,

I've been whaching the example you show on:

http://jsplayground.syncfusion.com/Sync_sn3ev02o

This example is just I need, but selecting the whole line instead.


I've being seeing concretely this:


           queryCellInfo: function (args) {
                    if (args.column !== undefined && args.column.field === "unitPrice") {
                        var $element = $(args.cell);
                        if (Globalize.parseFloat(Globalize.format(args.text, "c")) < 30) {
                            $element.css("background-color", "#b0e98f").css("color", "black");
                        }
                        else {
                            $element.css("background-color", "#f4a496").css("color", "black");
                        }
                    }
                }

I'd would like the same but selecting the whole line instead a cell, could you give me a example, I would be very grateful.

Thank you very mach

Regards,

Daniel Pujante

Prasanna Kumar Viswanathan [Syncfusion]
Replied On April 24, 2017 02:45 AM

Hi Daniel, 

Thanks for contacting Syncfusion support. 

To change the row background color, use rowDataBound event of ejGrid. This event will be triggered every time a request is made to access row information, element and data. In this event we can get the row element in the arguments and change the background color according to the value of unitPrice. 

Find the code example and sample:  


$("#Grid").ejGrid({ 
                dataSource: window.details, 
                enableRowHover: false, 
                allowSelection: false, 
                columns: [ 
                         ----------------------------- 
               ], 
                rowDataBound: function (args) { 
                        var $element = $(args.row); 
                        if (args.data.unitPrice < 30) { 
                            $element.css("background-color", "#b0e98f").css("color", "black"); 
                        } 
                        else { 
                            $element.css("background-color", "#f4a496").css("color", "black"); 
 
                        } 
                } 


Refer to the Help document for the rowDataBound event.  


Regards, 
Prasanna Kumar N.S.V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;