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

AllowRowSelect="True"

4 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mro
Top achievements
Rank 1
mro asked on 01 May 2008, 10:31 AM
Hi,
This is my third post since using new Prometheus controls (and that is only 2 weeks and only grid control). The first 2 problems are not yet solved and here is the new one.
I have a grid with check boxes and i do not want a user to be able to select a row if a check box is disabled, and i do not want a user to select a row by clicking on it and if the header check box is clicked i do not want the rows with disabled check boxes to be selected. It all worked in the previous rad grid like this:

 <script type="text/javascript">    
            var currentClickEvent = null;   
   
            function GridCreated()   
            {   
                var grid = this;   
                   
                //non-ie click event capture   
                //the event handler will get fired *before* the row click event    
                //and we use that to cache the current event object   
                if (grid.Control.addEventListener)   
                    grid.Control.addEventListener("click", GridTableClick, true);   
            }   
   
            function GridTableClick(e)   
            {   
                currentClickEvent = e;   
            }   
               
            //IE has a global event object. We get the previously cached event object for other browsers   
            function GetClickEvent()   
            {   
                return window.event || currentClickEvent;   
            }   
               
            //cancel all select/deselect operation triggered by non-checkbox row clicks   
            function CancelNonInputSelect(row)    
            {    
                var e = GetClickEvent();   
                //IE - srcElement, Others - target   
                var targetElement = e.srcElement || e.target;   
   
                //is the clicked element a checkbox? <input type="checkbox"...>   
                if(targetElement.tagName.toLowerCase() != "input" &&   
                    targetElement.type.toLowerCase() != "checkbox")   
                {   
                    //cancel the event   
                    return false;   
                }   
                   
                //clean up after all (de)selections are performed   
                window.setTimeout(function() {   
                    currentClickEvent = null;   
                   }, 0);   
            }    
          </script>   


and this is from the grid:

 
   <ClientSettings> 
   <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" ></Selecting
<ClientEvents OnGridCreated="GridCreated" OnRowSelecting="CancelNonInputSelect" OnRowDeselecting="CancelNonInputSelect" /> 
</ClientSettings> 


Now nothing works. I think i will go back to previous version.

4 Answers, 1 is accepted

Sort by
0
mro
Top achievements
Rank 1
answered on 01 May 2008, 04:16 PM
I forgot the question:
Can new Telerik Grid Q1 ASP.NET Ajax do this:
1. If check box is disabled prevent row selection.
2. When clicking on the select all do not select rows with disabled check boxes and check the "select all".
3. When unselecting "select all" unselect all.

If i have to search trough the forums all day what's the point then of using this? Microsoft grid view can do this if you spend all day on google.

Thank you,
Mario


0
Kiara
Top achievements
Rank 1
answered on 05 May 2008, 08:33 AM
Mario, I found these examples which might put you in the right direction:

http://www.telerik.com/community/code-library/submission/b311D-mkmkk.aspx
http://www.telerik.com/community/code-library/submission/b311D-hgmtb.aspx

Probably a combination/modification of these samples will give you the functionality you are searching for.

Kiara
0
mro
Top achievements
Rank 1
answered on 07 May 2008, 02:03 PM
Thank you Kiara but that did not help. As I said, I have a solutions which works fine with the old grid.
0
Kiara
Top achievements
Rank 1
answered on 07 May 2008, 02:25 PM
Oh, I missed that part, sorry. However, porting an old exisiting javascript code to the new RadGrid for ASP.NET AJAX may require some modifications. Use this help topic for further pointers.

Kiara
Tags
Grid
Asked by
mro
Top achievements
Rank 1
Answers by
mro
Top achievements
Rank 1
Kiara
Top achievements
Rank 1
Share this question
or