Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
UltraWebGrid change background row colour
posted

HI,

I am searching a row in ultrawebgrid and highlighting with "yellow" color.

I am highlighting the row from code behind.

e.g

rows.Style.BackColor = System.Drawing.Color.FromArgb(255, 255, 185)

Now my requirement is that after clicking outside row color should be change.I am doing this throuugh javacript.

row.Element.className = "deactiveColor"

"deactiveColor" is my classname.

I tried 

activeRow.Element.style.backgroundColor = "Red";

and

activeRow.Element.bgColor = 'red';

 

but this is not working.

Parents
  • 49378
    posted

    Hello juliep,

    Thank you for posting in the community.

    A possible straightforward approach may be to change the selected row style of your grid if your application allows that (i.e. if single selection is enabled).

    In order to change the backcolor of an activated row through javascript, the CSS has to be applied on the respective row's cells, and the previously activated row's color should be reverted. This may be achieved by handling the AfterRowActivate clientside event. For instance (using a bit of jQuery):

    Code Snippet
    1.     <script type="text/javascript" id="igClientScript">
    2. <!--
    3. oldActivatedRow =
    4. {
    5.     oldRow: null
    6. }
    7.  
    8. function UltraWebGrid1_AfterRowActivateHandler(gridName, rowId){
    9.     debugger;
    10.     var row = igtbl_getRowById(rowId);
    11.     var cellElements = row.getCellElements();
    12.     $(cellElements).css("background-color", "Green");
    13.  
    14.     if (oldActivatedRow.oldRow!=null) {
    15.         $(oldActivatedRow.oldRow.getCellElements()).css("background-color","White");
    16.     }
    17.  
    18.     oldActivatedRow.oldRow = row;
    19. }
    20. // -->
    21. </script>

    Please let me know if this helps.

Reply Children