Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPItextSuggest selection questiontextSuggest selection question
Previous
 
Next
New Post
5/21/2009 2:14 PM
 

I am using TextSuggest in a custom module and have the suggest part working.  I am filling a datatable and using it to get the suggest text from.  I have included my code below.

Now I am at a loss for how to get the information back!  I want the GUID (as a string or guid, it doesn't matter) back for the selected item to pull that school's information.  I would like it to be automatic using the NodeClick method if I'm correct on how that works.  That way there is no button to press, and they are limited to the choices in the textSuggest.

Is there a way to pull the OrgsID from the choice?  Or do I need to re-query the db based on the .text value of the textbox and match it to the guid that way?

I am using a slightly modified version of the example given by Michael Washington at:  http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/1067/Using-the-DNN-Text-Suggest-Control.aspx

Here is my code -- I am including some of the data access methods in case I'm not setting it up correctly to begin with (but the suggest text DOES work as expected currently):

    Private Sub PopulateList(ByVal objNodes As DNNNodeCollection, ByVal strText As String)

        Dim o As DNNNode
        Dim dt As DataTable = GetOrgs() 'fills the datatable

        'strip out troublesome chars for Select below
        strText = strText.Replace("[", "").Replace("]", "").Replace("'", "''")
        dt.CaseSensitive = Me.MyDNNTextSuggest.CaseSensitive
        Dim drs() As DataRow = dt.Select("OrgsName like '" & strText & "%'")
        Dim dr As DataRow
        For Each dr In drs
            If Me.MyDNNTextSuggest.MaxSuggestRows = 0 _
            OrElse objNodes.Count < (Me.MyDNNTextSuggest.MaxSuggestRows + 1) Then
                o = New DNNNode(CStr(dr("OrgsName")))
                o.ID = CType(dr("OrgsID"), Guid).ToString()
                objNodes.Add(o)
            End If
        Next

    End Sub

    Public Function GetOrgs() As DataTable

        GetOrgs = FillDataTable("select OrgsID, OrgsName from vwSchoolsInfo", "vwSchoolsInfo")

    End Function

    Private Function FillDataTable(ByVal strSQL As String, ByVal strTableName As String) As DataTable

        Dim dt As New DataTable()
        Dim conProjectTrack As SqlConnection = GetConnectionObject()
        Dim cmd As SqlCommand = conProjectTrack.CreateCommand
        Dim da As New SqlDataAdapter(strSQL, conProjectTrack)

        cmd.CommandType = CommandType.Text
        cmd.CommandText = strSQL

        da.SelectCommand = cmd

        da.Fill(dt)

        Return dt

    End Function

Thanks,

Kevin

 
New Post
5/29/2009 8:56 AM
 

It is possible to pull back the ID and text value on the client when the user clicks the selection.  This sample shows how to obtain the id.

However, I am a bit concerned that you are trying to use a control for a purpose it is not intended for.  Having the user choose a suggested item is optional.  If their browser does not support suggestions, a normal search needs to take place based off of what they typed. 


 
New Post
6/2/2009 7:11 PM
 

Jon,

Really cool example page. . .thanks, I thought I had been all over that site!

That helps a lot.  The only reason I wanted to do it 'on click' is that it's not really a true search, the only valid selections are the ones in the suggest list.  I guess that points out a valid flaw in my logic!  People will expect it to perform like a search even if they do not see the school they want in the suggest list.

Thanks for the tip,

Kevin

 
New Post
7/11/2009 9:04 PM
 

Sorry to dredge up old whining, but I have been banging my head on the wall on this for a few weeks off and on. I am still looking for a way to pull the ID back out of the node.  Further, I am not sure how to address the node on-click.  I am barely above a beginner in the programming department unfortunately (but I'm working on it!).

I cannot get the NodeClick event to fire when someone clicks on a suggestion.  I have it defined in the properties for the suggest box as MyDNNTextSuggest_NodeClick.

The way I am thinking of this, the code (from the original post above):

                o = New DNNNode(CStr(dr("OrgsName")))
                o.ID = CType(dr("OrgsID"), Guid).ToString()
                objNodes.Add(o)

would assign the OrgsName to the node, and the OrgsID to the node's ID.  I also see 'key' here (o.key) in some examples.  Either one I use, I can step through the code and see that the correct GUID (as a string) is added to the node.

The page you pointed me at with the examples looked promising at first.  Maybe it's just because I am not experienced in C#, but I'm not seeing how to address the node in VB or get the click event to fire using that code.  I am looking for a way to set a session variable with the ID or key (which is the GUID as a string) of the selected node.

I realize this does not function as a true 'search', but it serves the purpose we need.  Also we are going live in T-minus 3 weeks (oh Lord help me!) and I will have time to refine and improve some of this stuff later. . .Any direction or examples would be greatly appreciated.

Thanks,
Kevin

 

 
New Post
7/30/2009 8:11 PM
 

Again, the control is like a search box, as there is no guarantee they will click on the item.  To get the selected Key from the server side simply change the ID Token to something and when a normal postback occurs you can get the value.   Try it out on this page.  Keep in mind that the user is not obligated to choose an item, in which case you will need to read the text on the server and do the lookup server side.  If there is more than one option that matches, I suppose you can try and assume the first value.


 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPItextSuggest selection questiontextSuggest selection question


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out