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

Load map on nested row is expanded

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefania
Top achievements
Rank 2
Stefania asked on 12 Dec 2013, 10:07 AM
Hi,
I have a grid with a nested view. In my nested view I have to load a map.
How can I load a script on row expanded? Client or server side.
Is there a clientevents that I can use?

Script to load
//carico la mappa
         function LoadMap(lat, lon) {
             if (lat == "0")
                 return;
 
             var myLatLng = new google.maps.LatLng(lat, lon);
  
             var mapOptions = {
                 zoom: 2,
                 center: myLatLng,
                 mapTypeId: google.maps.MapTypeId.HYBRID
             }
  
             map = new google.maps.Map(document.getElementById("map"), mapOptions);
             infowindow = new google.maps.InfoWindow();
             createMarker(new google.maps.LatLng(lat, lon), "testo interno", "");
         }


       protected void HomeRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
       {
           switch (e.CommandName)
           {          
               case "ExpandCollapse":                   
                       //LOAD SCRIPT
                       break;
           }
       }

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 17 Dec 2013, 08:37 AM
Hi Stefania,

To achieve the desired functionality you can use the ScriptManager.RegisterStartupScript method into the RadGrid1_ItemCommand event. For example:
void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "ExpandCollapse")
        {
            if ((e.Item as GridDataItem).Expanded == false)
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "LoadMapScript", string.Format("LoadMap({0},{1})", 42.696804,23.328781), true);
            }
        }
    }
Additionally I am sending you a simple example which demonstrates it. Please check it out and let me know if it helps you.

Regards,
Radoslav
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Stefania
Top achievements
Rank 2
Answers by
Radoslav
Telerik team
Share this question
or