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

Stop row select on client-side?

9 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 14 Aug 2008, 11:58 PM
How can I stop row select by sending a confirm popup to user?

What I guess is
<ClientEvents OnRowSelecting="return confirm('select?');" />

But it seems not working.

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Aug 2008, 06:15 AM
Hi Darren,

Here is an example:
<ClientEvents OnRowSelecting="RowSelecting" />

function RowSelecting(sender, args)
{
    if(!
confirm('select?'))
       args.set_cancel(true);
}


Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Darren
Top achievements
Rank 1
answered on 15 Aug 2008, 04:06 PM
ty!
0
Darren
Top achievements
Rank 1
answered on 15 Aug 2008, 06:21 PM

The example you show here:

<ClientEvents OnRowSelecting="RowSelecting" />

function RowSelecting(sender, args)
{
    if(!
confirm('select?'))
       args.set_cancel(true);
}

"args.set_cancel(true);" works, but only when you click on row. It does not work on the checkbox "radG:GridClientSelectColumn".

Should I use different event for this purpose?
0
Darren
Top achievements
Rank 1
answered on 15 Aug 2008, 07:08 PM
After I check more examples on this forum. I figure out the problem is the column radG:GridClientSelectColumn actually triggered before the RowSelecting event.

To solve my problem, I just need a code to set the check value of radG:GridClientSelectColumn when it click. Can you please show me how to do so?
0
Yavor
Telerik team
answered on 18 Aug 2008, 07:25 AM
Hello Darren,

The selection is actually properly canceled in both cases - standard row selection and checkbox selection. This is demonstrated in the code project attached to this message. Take a look at it and let me know if I am leaving something out.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Darren
Top achievements
Rank 1
answered on 18 Aug 2008, 06:22 PM
Dear Yavor:

Thank you for the reply and code. Your sample works. After looking into your code. I found the Rad.Grid version I am using is an old one. Which is from 2007 Q1 Rad.Controls.
On the top register tag in .aspx page, you use:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
My page is:
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>

The version I am using seems has no RadScriptManager as well.

What is your suggestion? Do I post my question in wrong forum?
0
Yavor
Telerik team
answered on 19 Aug 2008, 06:56 AM

Hello Darren,

You actually chose the grid for asp.net Ajax, which is the one I used in the local tests.
Attached to this message,  is a sample using the classic version of the control. Take a look at it and let me know how it goes.

Kind regards,

Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Darren
Top achievements
Rank 1
answered on 19 Aug 2008, 06:24 PM
Thank you for the test. The result is same as I tested. When you use checkbox to select the row, the cancel button won't cancel the checkbox from being checked. It only works on row select.

Darren L.
0
Accepted
Yavor
Telerik team
answered on 25 Aug 2008, 05:28 AM
Hi Darren,

In this case, you will need to modify the code a little bit. Based on the sample sent earlier, you can use the following javascript code:

.Js
 <script type="text/javascript">    
                  
              function rowSelecting(row)  
              {  
                 
                document.getElementById("txbDescription").value ="test";  
                
              if(!confirm('select?'))  
                  {                     
                   var radGrid1 = window["<%=RadGrid1.ClientID %>"];  
                   var clientSelectCell = radGrid1.MasterTableView.GetCellByColumnUniqueName(row,"clientSelectColumn").innerHTML;  
                   radGrid1.MasterTableView.GetCellByColumnUniqueName(row,"clientSelectColumn").childNodes[0].checked=false;  
                   return false;                 
                  }  
              }       
      
        </script> 



Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Darren
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Darren
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or