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

RadGrid Row Selection with GridClientSelectColumn.

5 Answers 152 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
shahid Aleem
Top achievements
Rank 1
shahid Aleem asked on 05 Jul 2010, 04:59 PM
Hello guys,

when i am working with ajax update panel I am not able to get row.Index when user select any item. it is saying that row.Index is undefined. the same when i am doing with out update panel i can get. Any solution for this.


<script type="text/javascript">
    var a = Array;
    window.onload = function() {
        debugger;
        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) {
        debugger;
        var i = 0;
        while(typeof(a[i]) != "undefined")
        {
            if (a[i++] == row.Index)
            {
                return false;
            }
        }
    }
    </script>

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jul 2010, 10:47 AM
Hi Shahid,


I suppose you have attached 'Selecting' function to 'OnRowSelecting' client event of RadGrid and want to retrieve the corresponding row index.

If you are using RadControls for ASP.NET AJAX version, then use the following code to achieve the same.
Client Code:
 
<script type="text/javascript"
    function OnRowSelecting(sender, eventArgs) { 
        alert(eventArgs.get_itemIndexHierarchical());  // index 
    } 
</script> 
[The OnRowSelecting event has two parameters - 'sender' and 'eventArgs']


-Shinu.
0
shahid Aleem
Top achievements
Rank 1
answered on 06 Jul 2010, 11:08 AM
thanks that worked.
0
Tonino
Top achievements
Rank 1
answered on 10 Aug 2010, 02:13 PM
Hello

I just upgraded RadGrid from the 'classic' version to the 'ajax' version and stubled over this thread as row.Index was not working any more. I changed the code (using get_itemIndexHierarchical as suggested by Shinu):

function Selecting(sender, args) {
   var i = 0;
   while (typeof(a[i]) != "undefined") {
      if (a[i++] == args.get_itemIndexHierarchical()) {
         return false;
      }
   }
}

Now 'return false' gets executed if the conditions are met, but the problem is that the row still gets selected. Any idea on what else I should change for the migration from 'classic' telerik controls to solve that?

Here part of the markup:
<ClientSettings>
   <Selecting AllowRowSelect="True" />
   <ClientEvents OnGridCreated="GridCreated" OnRowClick="RowClick" OnRowSelecting="Selecting" />
</ClientSettings>

Regards,
Tonino.
0
Tonino
Top achievements
Rank 1
answered on 10 Aug 2010, 02:44 PM
I found the problem!

   return false;
shoud be changed in
   args.set_cancel(true);

regards,
Tonino.
0
Pavlina
Telerik team
answered on 10 Aug 2010, 04:21 PM
Hello Tonino,

I am glad to hear that you managed to solve the problem! In case you experience any other problems or you have additional questions, do not hesitate to contact us again!

Best wishes,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
shahid Aleem
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
shahid Aleem
Top achievements
Rank 1
Tonino
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or