Monday, October 8, 2012

How to refresh a grid in silverlight, when a launched window closes?

How to refresh a grid in silverlight, when a launched window closes?

I am launching a window using HtmlPage.Window.Navigate(Uri, "_blank"); from a Grid row using a context menu for some custom editing specific to a page referred by the row. I am using telerik-grid in silver-light. I want to refresh the grid when user closes that window. How can i do this?

Please share some idea on, Is this possible? or where to look for start to tackle this?

UPDATE: I am using Silver-light MVVM model. The child window I am opening from silver-light is the the web browser, I would actually need a technique where I can have the grid in the silver light application to get refreshed when I close the web browser. Additionally i am using RIA service to expose the methods for the web browser.

Answers & Comments...

Answer: 1

Expose a method in your Silverlight app that is accessible from Javascript.

namespace SilverlightApplication {     public partial class Page : UserControl     {         public Page()         {             InitializeComponent();              HtmlPage.RegisterScriptableObject("Page", this);                     }          [ScriptableMember]         public void UpdateDataGrid()         {             myDataGridItemsReload(); // your routine         }     } }  

Then in the newly opened window, you can execute a method on the Silverlight instance

<script>     window.onunload = refreshParentGrid;     function refreshParentGrid() {         var hostDiv = window.opener.document.getElementById("silverlightControlHost");         var control = hostDiv.children[0];                    control.Content.Page.UpdateDataGrid();     } </script> 
by : Chui Teyhttp://stackoverflow.com/users/34461




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog