This is a migrated thread and some comments may be shown as answers.

Coloring the button in Radgrid using javascript

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sannokia
Top achievements
Rank 1
Sannokia asked on 22 Jan 2014, 11:34 AM
 Hi

My issue is, while I have three buttons in one of the radgrid column, I need to show different color for different button as client clicks.
Now the challenge is, I have to do that from client side as I have to avoid the server trip which is around 20*3 = 60 times for 20 row grid.
Now I am getting the buttons and can set text into that but when I use the style.background property thats not working. any help will be highly appreciated.

Thanks,
SAN  

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 22 Jan 2014, 12:37 PM
Hello,

"style.background" property is not browser compatible.

Please Jquery or use conditional code to set style in button.

Please check below example for reference.

if (navigator.appName == "Microsoft Internet Explorer") {
                        version = parseFloat(navigator.appVersion.split("MSIE")[1]);
                        if (version == 7) {
                            btn.style.backgroundColor = '#000000';
                        }
                        else {
                            btn.setAttribute("style", "background-color: #000000;");
                        }
                    }
                    else {
                      btn.setAttribute("style", "background-color: #000000;");
                    }


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Sannokia
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or