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

[Solved] Disable selection for some rows in GridClientSelectColumn conditionally

2 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 02 Jun 2009, 10:32 AM
Hi All,

I am trying to disabled selection for some rows base on my condition. I can successfully disabled the checkbox column. But when i click the row, i got the row.Index is underfined in function Selecting(row). Here is my code. Please let me know how can i get the row index to compare with my disabled index.

Thanks,
Alex

<

 

ClientSettings>

 

 

<Selecting AllowRowSelect="True" />

 

 

<ClientEvents OnRowSelecting="Selecting" />

 

 

</ClientSettings>

<script type="text/javascript"
    var a = Array; 
    window.onload = function () 
    { 
        var inp = document.getElementById('Sel'); 
        var data = inp.value; 
        if(data != ""
        { 
            var rowsData = data.split(":"); 
            var i=0; 
            while(typeof(rowsData[i]) != "undefined"
            { 
                if (rowsData[i] != ""
                { 
                    a[i] = rowsData[i]; 
                } 
                i++; 
            } 
        } 
    }     
    function Selecting (row)  
    { 
        var i = 0; 
        while(typeof(a[i]) != "undefined"
        { 
            if (a[i++] == row.Index) 
            { 
                return false
            } 
        } 
    } 
    </script> 

 

2 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 02 Jun 2009, 11:01 AM
Hi All,

I am using the wrong argument for Selection() function. I should use as follow. Now function return false if selected row index and disabled checkbox index but still can select the row and check box is checked. Please let me know. Thanks.

 function Selecting (sender, eventArgs)  
    { 
        var i = 0; 
        while(typeof(a[i]) != "undefined"
        { 
            if (a[i++] == eventArgs.get_itemIndexHierarchical()
            { 
                return false
            } 
        } 
    } 
0
Alex
Top achievements
Rank 1
answered on 02 Jun 2009, 11:07 AM
Solved.

using 

eventArgs.set_cancel(

true) instead of return false.

 

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