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
90
Javascript and readonlygrid
posted

 Hi,

        I have ultrawebgrid with readonly set to level 0, this is done as grid needs to display approx 10,000 rows of record in single page and with readonly not set grid is almost dead. so far so good problem am facing is I also need onclick javascript event fired on click of row, how can I achieve this?

Parents
  • 28464
    Verified Answer
    posted

    Indeed, the client-side CellClickHandler client-side event is not fired when the ReadOnly property of the grid is set. I managed to find a workaround that may work in your case though. The idea is to create a div wrapper that hosts the grid and trap its onclick handler, then inspect the event arguments of the event to figure out the exact row. Rows have ids prefixed by the client side ID of the grid and ending with the index of the row. Here is my approach:

        <div id="divPlaceholder">  
        
        <igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server"

        </igtbl:UltraWebGrid>
       
        </div>
       
        <script type="text/javascript">
       
        document.getElementById("divPlaceholder").onclick = handleClick;
       
        function handleClick(e)
        {
          
           
            var sourceElement = (e.srcElement) ? e.srcElement : e.target;
           
            if (sourceElement.tagName == "TD")
            {          
                var parentRow = sourceElement.parentNode;           
                var lastIndex = parentRow.id.lastIndexOf('_');           
                var id = parentRow.id.substring(lastIndex + 1);
               
                alert(id);
            }
           
        }
       
        </script>

     

    Hope this helps. 

Reply Children
No Data