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

Checking CHECKBOX in RadGrid

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ky
Top achievements
Rank 1
Ky asked on 01 Dec 2011, 03:51 AM
Dear all,
I want to write a javascript function  to check a List using CheckBOX in RADGRID below:

If there is no item is checked=> return false;
If there is one or more item(s) is checked=> return true;

Please help me to do it
Thanks alot,

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Dec 2011, 05:30 AM
Hello,

Try the following JS.

JS:
<script type="text/javascript"
function OnClientClick()
 {
    var grid = $find('<%=RadGrid1.ClientID %>');
    var count = grid.get_masterTableView().get_selectedItems().length;
    if (count == 0)
    {
      //your code
    }
   else
    {
      //your code
    }
 
</script>

Thanks,
Princy.
0
Ky
Top achievements
Rank 1
answered on 01 Dec 2011, 10:37 AM
Thanks very much,

and I have other problem: I use  button Control <asp:Button runat="server" ID="btnValidation" OnClientClick="javascript:return OnClientClick(); " Text="[text validation]" />

<script type="text/javascript"
function OnClientClick()
 {
    var grid = $find('<%=RadGrid1.ClientID %>');
    var count = grid.get_masterTableView().get_selectedItems().length;
    if (count == 0)
    {
      return false;
    }
   else
    {
      return true;
    }
 
</script>

When I click check a checkbox=> it means OnClientClick function will return TRUE;
BUT there is NO ACTION it doesn't work (not post back to server).

Even thought, I changed:
<asp:Button runat="server" ID="btnValidation" OnClientClick="javascript:return true; " Text="[text validation]" />

it doesn't work too.

I don't know is there any problem when using TEELRIK??
If I don't use TELERIK it works normal!

Please help me to do it.

Thanks alot
Tags
Grid
Asked by
Ky
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ky
Top achievements
Rank 1
Share this question
or