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
498
add a onmouseover handler to a row in a webgrid on the client side
posted

I'm trying to change the background color of a row in a webgrid onmouseover on the client side. Is there a way to do this.

Thank you.

  • 5
    posted

     Hi, just tried to implement this solution, (as a test to see what was going wrong),

    the original and now additional problem was trying to the show a Context Menu (as UltraWebMenu) on right click.

     

    I've suddenly also picked up a couple of hundred javascript errors, which makes me think its down to this:

    igmenu_showMenu(etc etc)

     

    I'm thinking, its not finding this command, possibly due to the convoluted series of frameworks I have installed on my development machine.

    (I have tried attaching several of the javascript files from 'C:\Inetpub\wwwroot\aspnet_client\Infragistics\20082CLR20\Scripts'  which appears to be where it should be looking... To no avail, yet it finds the images required for the controls ok)

    Is there an easy way to find out exactly what functions/images etc, are required for each control, and add them to my solution, and point the infragistics controls to this instead?

    --EDIT NOTE: I realized in reading other posts, that the fact that the grid, is in a user control, placed into a Content Page(w/ MasterPage), may have some bearing on the number of javascript errors, perhaps its down to the naming?

    Regards and thanks,

       Andrew Wilson
       Stripe Consulting

  • 7694
    Verified Answer
    posted

    Hello,

    You can use the ClientSideEvents of UltraWebGrid and use events MouseOverHandler="Over" MouseOutHandler="Out" . With javascript function over and out you can manipulate background of rows:

    <ClientSideEvents MouseOverHandler="Over" MouseOutHandler="Out"/>

    ...

    <script type="text/javascript" language="javascript">   

        function Over(gridNane, cellID, objectType){       

            var cell = igtbl_getCellById(cellID);

            setRowBackColor(cell.Row, "red");        

        }

        function Out(gridNane, cellID, objectType){       

            var cell = igtbl_getCellById(cellID);

            setRowBackColor(cell.Row, "white");    

        }

        function setRowBackColor(row, color){

            var cells = row.getCellElements();       

            for (var i = 0; i < cells.length; i++) {

                cells[i].style.backgroundColor = color;       

            }  

        }

        </script>

    ...