Hello
I have a Webgrid inside a WARP and a WebImageButton outside it. I would like to handle the Client-Side AfterSelectChange event of the grid in such a way that if the value of the "HasPDF" cell of the selected row is 1 the button has to be enabled and disabled otherwise, having that there is single selected row (the button has to be disabled if there is not a single selected row).
Since I do not know much of CSOM, I would appreciate any coding help you can give me.
Thanks a lot.
Hi,
You need to handle this in client side using java script function. You can refer following sample function.
Add event handler for client side function using this code in your .aspx file.
<ClientSideEvents BeforeEnterEditModeHandler="grid_BeforeEnterEditMode" />
Following is the function.
function grid_BeforeEnterEditMode(gridName,cellId)
{
var cell = igtbl_getCellById(cellId);
var row = cell.Row;
var compareValue = row.getCell(0).getValue();
//or use this following line if you want to use column name instead of index
var compareValue = row.getCellFromKey("SD").getValue();
if(compareValue != 'Dynamic')
return true;//Row could not be edited
}
else
return false;//Row is editable
I hope this would help you.
protected void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { Color backColor; string strDynCnt = e.Row.Cells.FromKey("SD").Value.ToString(); if (strDynCnt == "Dynamic") { backColor = System.Drawing.Color.LemonChiffon; e.Row.Style.BackColor = backColor; e.Cancel = false; } else { e.Cancel = true; } }
Try this code.
(1) Adding event handler
<ClientSideEvents
AfterRowActivateHandler="grid_AfterRowActivate" />
(2) function
function grid_AfterRowActivate(gridName,rowId)
var row = igtbl_getRowById(rowId);
var imgButton = ig_getWebControlById("<%= WebImageButton1.ClientID %>");
if(row.getCellFromKey("HasPDF").getValue() == 1)
imgButton.setEnabled(true);
imgButton.setEnabled(false);
I think you also need to select first row at first time load. You can handle this in Initialize layout handler event.
Let me know if this helps you.
Greetings