Welcome Guest Search | Active Topics | Sign In | Register

function javascript on a CheckBoxColumn Options
maxime
Posted: Thursday, December 3, 2009 6:14:06 AM
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.
eo_support
Posted: Thursday, December 3, 2009 10:06:15 AM
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.