Rank: Newbie Groups: Member
Joined: 8/24/2009 Posts: 6
|
Hello,
I would like add a javascript function on a CheckBoxColumn. When the user check or uncheck a checkbox, i would like show a confirm message to the user.
Can I add my own function or I must use 'on_end_edit' and if yes, how ?
I work in code behind and I defined my column like this : CheckBoxColumn cc = new CheckBoxColumn(); cc.HeaderText = drGC[Constants.Factory.FACTORY_CODE].ToString(); cc.DataField = drGC[Constants.Factory.FACTORY_CODE].ToString(); cc.Width = 40; cc.CheckBoxStyle.CssText = "text-align: center"; cc.CellStyle.CssText = "text-align: center"; cc.AllowSort = false; gvCountryWithNLBis.Columns.Add(cc);
Thanks for your help.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Try place the following code after the Grid:
Code: JavaScript
//Save the old dispatcher function
var old_grid_dispatcher = eo_Grid_Dispatcher;
eo_Grid_Dispatcher = function(e, id, cmd, arg)
{
//Get the grid object
var grid = eo_GetObject("Grid1");
//Get the cell that was clicked
var cell = grid.getItem(arg[0]).getCell(arg[1]);
//Get the original cell value
var oldCellValue = cell.getValue();
//Call the old dispatcher
old_grid_dispatcher(e, id, cmd, arg);
//Restore the cell value if user does not confirm
if (!confirm("Are you sure?"))
cell.setValue(oldCellValue);
}
The code replaces one of our Grid's core function and displays a confirm message box. If user selects no then it restores the cell's value. Thanks!
|