This is a migrated thread and some comments may be shown as answers.

Grid: ask for confirmation on select all

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kiwo
Top achievements
Rank 1
kiwo asked on 30 Jul 2009, 06:36 PM
Hi.

I have a GridClientSelectColumn in my grid. The feature I need is the following:
When SELECT ALL checkbox is checked or unchecked, before it performs the action, confirmation message is required, depending on the status:
"Are you sure you want to ...(select/deselect all entries)"
.

How do I accomplish that?
Thanks!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2009, 04:51 AM
Hello,

Try the following code snippet in order to show confirm on checking/unchecking the header checkbox of GridClientSelectColumn.

ASPX:
 
<telerik:GridClientSelectColumn UniqueName="Selectcolumn" Text="Select" HeaderText="Select"
</telerik:GridClientSelectColumn> 

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridHeaderItem) 
    { 
        GridHeaderItem item = (GridHeaderItem)e.Item; 
        CheckBox chkbx = (CheckBox)item["Selectcolumn"].Controls[0]; 
        chkbx.Attributes.Add("OnClick""showConfirm('"+chkbx.ClientID+"');"); 
    }        

JavaScript:
 
<script type="text/javascript"
function showConfirm(chk) 
    var c = document.getElementById(chk); 
    var grid = $find("<%=RadGrid1.ClientID %>"); 
    if(confirm('Do you want to select/unselect all ...?')) 
    { 
        if(c.checked) 
        { 
            grid.get_masterTableView().selectAllItems(); 
         
        } 
        else 
        { 
             grid.get_masterTableView().clearSelectedItems(); 
        } 
    } 
    else 
    { 
        c.checked= !c.checked; 
    } 
</script> 
Happy coding.. :)

-Shinu.
Tags
Grid
Asked by
kiwo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or