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
622
Display the data of the selected cell in a text using Java Script
posted

Hi All,

Always I need to display the first column data available in the selectec cell's row in a Label using Java Script..

Regards,

Abhi

  • 45049
    posted

    Do you mean the "active cell", as in the cell that has input focus?  Or do you instead actually mean a "selected cell", of which there may be more than one, such as by highlighting multiple cells at once?

    I'm going to write the below JavaScript with the assumption you mean the "active cell," since WebGrid either has one active cell or none at all.  I'm also assuming that you're not hiding any columns or allowing them to be re-ordered on the client, so that the first column displayed has an index of 0.  Lastly, I'm using an alert() dialog to show the data.

    Also note that I don't have a development environment on-hand at the moment, so I haven't tested this.

    var grid = igtbl_getGridbyId("UltraWebGrid1"); // replace with the ClientID of your WebGrid

    var cell = grid.getActiveCell();

    if (cell == null)
    {
        alert("There is no active cell.");
    }
    else
    {
        var firstCellValue = cell.Row.getCell(0).getValue();
        alert(firstCellValue);
    }