6 Replies Latest reply on Aug 5, 2010 1:53 PM by spilon

    Custom WebPart - RtTreeView parameter Consumer

    derendoff

      Hello,

       

      Does anyone have sample web part code that receives parameters from the RtTreeView web part? 

       

      The Webinar example provided by OSI shows a web part that provides parameters but the inverse is not clear.

       

      I'm attempting to use the currently selected Module Path to query our SQL database for related Alarms and Logs in our custom notification viewer.

       

      Thanks.

       

      Shane

        • Re: Custom WebPart - RtTreeView parameter Consumer
          Asle Frantzen

          Hi Shane

           

          Yes, I should have some code for that. Let me take a look!

            • Re: Custom WebPart - RtTreeView parameter Consumer
              Asle Frantzen

              So I found some code, and put it into an example webpart - which is attached. There's a link to "C:\Example" where the javascript file must be placed when compiling.

               

              The important parts would be these two methods, where you iterate through the ParameterNames of the available Properties being sent from the RtTreeView webpart:

               

              Server Side Connection Interface

              
              

              /// <summary>
                /// Handles Ready event raised by provider
                /// </summary>
                /// <param name="sender">Provider web part</param>
                /// <param name="inParametersOutReadyEventArgs">Contains parameter values sent</param>
                public void ParametersOutReady(object sender, ParametersOutReadyEventArgs inParametersOutReadyEventArgs)
                {
                 try
                 {
                  ParametersOutReadyEventArgs = inParametersOutReadyEventArgs;
                  if(ParametersOutProviderInitEventArgs != null)
                  {
                   for (int i=0; i < ParametersOutProviderInitEventArgs.ParameterOutProperties.Length; i++)
                   {
                    if (ParametersOutProviderInitEventArgs.ParameterOutProperties.ParameterName.ToUpper()=="MODULEPATH")
                    {
                     _wp.ModulePath = ParametersOutReadyEventArgs.ParameterValues;
                    }
                   }

                   this.ModulePath = _wp.ModulePath;
                  }
                 }
                 catch (Exception ex)
                 {
                  throw(ex);
                 }
                }

               

               

               

              Client Side Connection Interface

              
              

              function myParametersOutReady(sender, ParametersOutReadyEventArgs)
               {
                try
                {
                 _ParametersOutReadyEventArgs_WPQ_ = ParametersOutReadyEventArgs;
                 
                 if(ParametersOutReadyEventArgs.ParameterValues != null)
                 {
                  for (i=0; i < _ParametersOutProviderInitEventArgs_WPQ_.ParameterOutProperties.length; i++)
                  {
                   if (_ParametersOutProviderInitEventArgs_WPQ_.ParameterOutProperties.ParameterName=="ModulePath")

                    modulepath_WPQ_ = ParametersOutReadyEventArgs.ParameterValues;     
                  }    
                  
                  updateHtml_WPQ_();
                 }
                }
                catch (ex)
                {
                 j=0; //Fix - needs to be present for javascript code to work
                }
               }

               

               

               

              Give it a try, and just ask if there's anything else you want to know!

                • Re: Custom WebPart - RtTreeView parameter Consumer
                  derendoff

                  Thanks Asle,

                   

                  I'll import the sample code and tailor for my solution and let you know how it goes.  Appreciate the quick reponse.

                   

                  Shane

                    • Re: Custom WebPart - RtTreeView parameter Consumer
                      Asle Frantzen

                      Sure, no problem!

                       

                       

                       

                      In all my webparts, I also have a function called GetWebpartHtml(...) which is called from a webservice. The webservice is the starting point for getting content updates from a database, and the webservice function in question is called from both javascript code and c# code. Directly after receiving parameters client side (javascript) and server side (c#) - I also call the webservice.

                       

                      The webservice then creates an object of my webpart by calling the constructor, and then I can access the GetWebpartHtml(...) passing along the parameters to indicate which content I want returned. GetWebpartHtml then calls the EnsureChildControls() and this initiates the normal procedure of constructing the html to be displayed - including data from the database.

                       

                      GetWebpartHtml(...) returns a string of html code to the webservice, which in turn returns the same string to the caller - so that the webpart can be updated with new contents.

                       

                       

                       

                      Please note that this functionality is not included in the sample webpart, but it gives an idea of what you can do to get AJAX style updates with content from a database.

                  • Re: Custom WebPart - RtTreeView parameter Consumer
                    saxyogi

                    Hi Guys,

                     

                    I am new to this forum. I have same issue as Shane did have. I want to use "PI Tree View" webpart as left menu. This would read data from AF and display them into a tree style. I am supposed to develop a Custom Web Part that would filter the information on the basis of selected node from "PI Tree View" webpart. Idea is that enduser should able to select some node in TreeView and Custom Webpart should consume the information from "PI WebPart" and act accordingly.

                     

                    My question is : Do you guys have a step by step document to develop a Custom Web Part that would consume Information from PI Tree View Web Part?

                     

                    I saw Asle's code and tried it using. However I am not able to understand fully.

                     

                    Any help in this regard would be highly appreciated.

                     

                    Thanks.