code_junkie

highlighting gridview rows for striped gridview from checkbox

Nov 13th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. var color = '';
  2. function changeColor(obj) {
  3. var rowObject = getParentRow(obj);
  4. var parentTable = document.getElementById("gvCategories");
  5. if(color == ''){
  6. color = getRowColor();
  7. }
  8. if(obj.checked){
  9. rowObject.style.backgroundColor = 'Yellow';
  10. }
  11. else{
  12. rowObject.style.backgroundColor = color;
  13. color = '';
  14. }
  15.  
  16. // private method
  17. function getRowColor(){
  18. if(rowObject.style.backgroundColor == '') return parentTable.style.backgroundColor;
  19. else return rowObject.style.backgroundColor;
  20. }
  21. }
  22.  
  23. // This method returns the parent row of the object
  24. function getParentRow(obj){
  25. do{
  26. obj = obj.parentElement;
  27. }
  28. while(obj.tagName != "TR")
  29. return obj;
  30. }
  31.  
  32. function highlightRow(object) {
  33. if ($(object).attr("checked") == true) {
  34. alert('is checked!'); // this will fire
  35. $(object).parent('tr').addClass("highlightedRow");
  36. }
  37. else {
  38. alert('is not checked!');
  39. $(object).parent('tr').removeClass("highlightedRow");
  40. }
  41. }
  42.  
  43. $(document).ready( function() {
  44. $('.rowCheckbox').click( function() {
  45. if (this.checked) {
  46. $(this).parent('tr').addClass('highlight');
  47. }
  48. else {
  49. $(this).parent('tr').removeClass('highlight');
  50. }
  51. });
  52. });
  53.  
  54. $(this).parents('tr').addClass('highlight');
  55.  
  56. $(object).parent('tr')
  57.  
  58. .addClass('highlight');
  59.  
  60. .SpatialDataHighlightedRow {
  61. background-color: #DDDDDD !important;
  62. }
Add Comment
Please, Sign In to add comment