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
650
Get a Selected Value of a cell in a Ultragridweb
posted

Good Morning Guys,

 

Can someone post a snipet code on how to get a value of a selected cell in a Ultragridweb.

 

Thank you

  • 45049
    Verified Answer
    posted

    In server-side C# code:

    using Infragistics.WebUI.UltraWebGrid;
    ...
    if (ultraWebGrid1.DisplayLayout.SelectedCells.Count > 0)
    {
        UltraGridCell selectedCell = ultraWebGrid1.DisplayLayout.SelectedCells[0];

        // In practice, you'd cast this to the appropriate data type for the corresponding column
        object cellValue = selectedCell.Value;
    }

    In client-side JavaScript code:

    var grid = igtbl_getGridById("<%= ultraWebGrid1.ClientID %>");
    if (grid.SelectedCells.length > 0)
    {
        var selectedCell = grid.SelectedCells[0];
        var cellValue = selectedCell.getValue();
    }

  • 14049
    Offline posted
    Hello,

    In the CSOM docs you can see a snippet for the selected rows:
    http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR3.5/html/WebGrid_Object_CSOM.html

    In the like manner you can iterate through the selected cells:

    for(var cellId in grid.SelectedCells)
    {
    var cell=igtbl_getCellById(cellId);
    alert(cell.getValue());
    }

    If you need the value from current cell (active cell) you can do it like
    this:
    grid.getActiveCell().getValue()