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

Client side SelectedRows

3 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 2
Iron
Iron
Pierre asked on 15 Dec 2008, 09:23 PM
Hi, after updating to the last version, this client code stop fonctionning:

 

for (var i = 0; i < grid.MasterTableView.SelectedRows.length; i++)

 

{
    ... 

 

 

 

}

i got a not defined error on the MasterTableView
I try this:

for

 

(var i = 0; i < grid.get_masterTableView().SelectedRows.length; i++)

 

 

{
    ... 

 now i got this objet do not have this properties.

any suggestion? Thanks

 

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Dec 2008, 07:52 AM
Hello Pierre,

Here is an example:

for (var i = 0; i < grid.get_masterTableView().get_selectedItems().length; i++)
{
    // your code goes here
}

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pierre
Top achievements
Rank 2
Iron
Iron
answered on 16 Dec 2008, 01:16 PM
I got the same error: here all the function. Can you help my to convert it correctly?

            function OnLogoChange(sender, eventArgs)  
            {  
               <telerik:RadCodeBlock runat="server">  
               var grid = window["<%= RadGridComm.ClientID %>"];  
               </telerik:RadCodeBlock> 
                 
                 
                 
               for (var i = 0; i < grid.get_masterTableView().get_selectedItems().length; i++)  
                {     
                    var Row = grid.get_masterTableView().get_selectedItems()[i];  
                    var ID = grid.get_masterTableView().GetCellByColumnUniqueName(Row, "ID");  
                    var oWindow = radopen ("/Site/Usager/ChangePhoto.aspx?sUID=" + ID.innerText + "&sType=Logo", "ChangeLogo");  
                }    
                                
            } 
0
Iana Tsolova
Telerik team
answered on 16 Dec 2008, 03:56 PM
Hi Pierre,

I looked at your code and here are my findings:
  • The RadCodeBlock control should not be placed inside a client function. It should surround the <script> tag. Find more infomration about RadCodeBlock here.
  • In order to access the grid client-side object, you need to use the $find() method as described here.

Please try modifying your code as below and let me know if it makes any difference:

<telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">  
<script type="text/javascript">     
function OnLogoChange(sender, eventArgs)     
{     
    var grid = $find("<%= RadGridComm.ClientID %>");     
    for (var i = 0; i < grid.get_masterTableView().get_selectedItems().length; i++)     
    {        
        var Row = grid.get_masterTableView().get_selectedItems()[i];     
        var ID = grid.get_masterTableView().GetCellByColumnUniqueName(Row, "ID");     
        var oWindow = radopen("/Site/Usager/ChangePhoto.aspx?sUID=" + ID.innerText + "&sType=Logo""ChangeLogo");     
    }                                       
}  
</script>  
</telerik:RadCodeBlock> 

All the best,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Pierre
Top achievements
Rank 2
Iron
Iron
Answers by
Vlad
Telerik team
Pierre
Top achievements
Rank 2
Iron
Iron
Iana Tsolova
Telerik team
Share this question
or