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. Image for the cookie policy date

How to change a row's background-color or color comparing pieces of information

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

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team April 24, 2017 06:45 AM UTC

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 


Loader.
Live Chat Icon For mobile
Up arrow icon