Loading...

How to get the current selected value from qSelector programmatically?

How to get the current selected value from qSelector programmatically?

  • This topic is empty.
Viewing 5 reply threads
  • Author
    Posts
    • #4896
      Anonymous
      Anonymous
      Participant

      Hi Inge,

        Please take a look to the Quest Web Parts instllation folder and you'll find a Visual Studio project that provides a working sample code.

      You can customize that code, you can access selected values from selectors, text from text boxes, perform validations, etc.

      Check the QWP docuemntation about how to embed your code into our web parts

      Please let me know if you have any other questions.

    • #4221
      Anonymous
      Anonymous
      Participant

      Hi,

      Is there a way to get the current selected value from the qSelector programmatically? E.g.:

          

                  using (SPSite site = new SPSite(rootFolderURL))            {                using (SPWeb web = site.RootWeb)                {                    web.AllowUnsafeUpdates = true;                    string webPartUrl = rootFolderURL + (rootFolderURL.EndsWith(“/”) ? “default.aspx” : “/default.aspx”);                    SPLimitedWebPartManager webParts = web.GetLimitedWebPartManager(webPartUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);                    foreach (WebPart webPart in webParts.WebParts)                    {                        string title = webPart.Title;                        if (!string.IsNullOrEmpty(title) && title.ToLower().Equals(“MY_QSELECTOR_TITLE”))                        {                            // Cast the webpart to the correct type and get the current qSelector value                            // Do stuff                            break;                        }                    }                }            }

      Best regards,

      Inge

    • #6573
      Anonymous
      Anonymous
      Participant

      Hi ,

      I looked at the Quest Web Parts installation folder and found the sample code you mentioned. I also looked at the QWP documentation and it says the following:

      "The Custom Action capability enables you to write a custom code that can be called from qListView, qListForm, qSIListView or qSIListForm Web Parts."

      It does not mention qSelector, so is the qSelector really supported in regard to the usage of Custom Actions?

      Also when looking at the code comments in the pleCustomActionEx class, I found the following comment:

      "The Perform method will be called by the webpart when the action item (such as toolbar button or context menu item) is clicked."

      Assuming the qSelector is supported in this regard, I take it that the "Perform" method would be called when a user clicks on a value in the qSelector's dropdown list. My problem is that I want to ask the qSelector about it's current selection when the user clicks the "Add new item" link (for a list that is filtered by the qSelector). More specific, I want to ask the qSelector about it's current value when the NewForm opens.

      I also looked at the System Integration Developer Guide and the custom Configurator example, but since I am not using any external data (just a standard SP list on the same page) and thus ain't using the qSISelector, I got the impression that this approach wasn't suited for my problem. Please correct me if I am wrong

      Best regards,

      Inge

    • #4899
      Anonymous
      Anonymous
      Participant

      I finally came up with a solution that worked fine for me:

      I made a custom webpart (hidden) that got the selected value from the qSelector through the standard webpart connection. I then extended the standard NewForm and fetched the custom webpart through the code I posted initially, and got hold of the selected value through a property containing the value. This now happends when the user clicks the "Add new item" link and the NewForm opens

    • #6570
      Anonymous
      Anonymous
      Participant

      Hi Inge

      I just saw your posted question and your answer. Sorry to be late but there may be a quick way to get the selected value. The qSelector contains a required property named "SessionName". This property is used to store the currently selected item in the session by that property value. So I assume that you can access the session value by that name from the Custom Action code you posted before to acess the selected value of the qSelector.

      Please note the value stored in this session is actually a Hashtable containing the Display Field name (defined in Display Fields property of qSelector) and the value of that field in the selected row. For example, you may get the selected row ID with the following code:

      Hashtable persistedData = (Hashtable)Page.Session[SessionName];
      if (persistedData != null && persistedData["ID"] != null)
      {
         selectedItemID = persistedData["ID"].ToString();
      }

      If you would like to give it a try, let me know if it works for you.

      Thanks,

    • #6571
      Anonymous
      Anonymous
      Participant

      Hi ,

      Thank you for your reply

      I have tested your proposal and it worked like a charm. I had no problem incorporating your code proposal into my own code.

      Best regards,

      Inge

Viewing 5 reply threads

You must be logged in to reply to this topic.