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
40
ultrawebgrid button cell
posted

Hi,

 I have an ultrawebgrid and one of the columns is a button type. When the user clicks this button, I need to grab the key field from the grid and display a modalpopup. Can somebody tell me how to do that?

 This is the code i have on the page_load

if (!IsPostBack)

{

// Create the template and add to it.

UWG1.Columns.Insert(0, "View");

UWG1.Columns[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Button;

UWG1.Columns[0].Width = Unit.Pixel(100);

 

UWG1.DisplayLayout.Bands[0].Columns[0].Header.Caption =
"View Profile";

BindData();

}

 

  • 236
    posted

    Put the following in the Initailizelayout event of the grid:

    protected void UWG1_InitializeLayout(object sender, LayoutEventArgs e)

    {

    e.Layout.Bands[0].Columns.Insert(0,
    "View");

    e.Layout.Bands[0].Columns.FromKey("View").Header.Caption = "View";

    e.Layout.Bands[0].Columns.FromKey("View").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Button;

    e.Layout.Bands[0].Columns.FromKey("View").Width = Unit.Pixel(100);

    e.Layout.Bands[0].Columns.FromKey("View").CellButtonDisplay = CellButtonDisplay.Always;e.Layout.ClientSideEvents.ClickCellButtonHandler = "UWG1_ClickCellButtonHandler";

    }

     

    then on the client side add the following:

    <script id="igClientScript" type="text/javascript">

    <!--

    function UWG1_ClickCellButtonHandler(gridName, cellId){

    //Add code to handle your event here.

    var cell=igtbl_getCellById(cellId);

    var keyValue=cell.Row.getCell(1).getValue(); //1 is the index of the key field, replace with your field index of the key

     

    alert(
    'Do your thing with key value of ' + keyValue);

    }

    // -->

    </script>