emaynard Posts:31
 |
| 04/27/2007 6:21 AM |
|
I'm still trying to get my first "Hello World" learning module built, so forgive me for asking all these questions. In most option list scenerios that I have worked with in the past, you have would have a text/value column pair that provides a friendly display text and the usually less friendly value for an optoin list. I don't see any kind of provision for this in the Option List Manager. Am I missing it or is there another way to handle this? One good example of this would creating a listbox or dropdown of portal Users. The numbers are really meaningless if you have even a small number of users to remember. thanks, -eric |
|
|
|
|
host Posts:93
 |
| 04/27/2007 7:13 AM |
|
| Are talking about the Sql List Option? The Manual and Module list options provide for this but the Sql only allows a value. Very good point, I'm surprised no one brought this up before. We'll take a look at that. |
|
|
|
|
emaynard Posts:31
 |
| 04/27/2007 3:19 PM |
|
Yes I was taling specifically about the SQL portion. Sorry to have left that out and thanks for looking into it.
Like I said, I can't imagine doing anything with anything other than a few list entries without the friendly text.
-eric |
|
|
|
|
emaynard Posts:31
 |
| 04/27/2007 5:04 PM |
|
From what i can make of the generated source, it looks like it is possible to have a friendly text setting: We would just have to have it read something more like this (changes noted by **) Protected Sub SetRecipientIDListOptions() Dim myCStr As String = Config.GetConnectionString Dim oconnection As New SqlClient.SqlConnection(myCStr) oconnection.Open() Dim oCommand As New SqlClient.SqlCommand("Select [UserID]**, [DisplayName]** from [vw_Users] Group by [UserID] [PortalId] = {PortalID} HAVING [UserID] Is Not Null Order by [UserID]", oconnection) Dim oDataReader As SqlClient.SqlDataReader = oCommand.ExecuteReader(CommandBehavior.CloseConnection) While oDataReader.Read() Dim newListItem As New ListItem newListItem.Value = oDataReader("UserID") newListItem.Text = oDataReader("**DisplayName**") cmbRecipientID.Items.Add (newListItem) End While UserID is the option list VALUE setting DisplayName is the option list TEXT setting (ps we need some basic formatting in the forums) hth, -eric |
|
|
|
|
emaynard Posts:31
 |
| 04/27/2007 5:06 PM |
|
(Crap, We need edit rights as well.)
That was the Add_xxxxxx.ascx.vb template by the way. |
|
|
|
|
emaynard Posts:31
 |
| 04/27/2007 5:26 PM |
|
Another thing to note about the code above.
You will see I made the rookie mistake of trying to use tags in the source instead of inside a template. That doesn't work too well!
Also the WHERE keyword was not created by the code gen. I will submit a bug report for this.
-e
|
|
|
|
|
host Posts:93
 |
| 04/27/2007 6:07 PM |
|
| Thanks for the catch Eric, we have corrected this issue and should be getting out a new build in a couple days. |
|
|
|
|
emaynard Posts:31
 |
| 04/27/2007 8:51 PM |
|
Actually, Now that I've work through it a bit, I think I may know why it wasn't there before.
There is really not a convenient way to pull that friendly text value into a template. I don't see any tag structure that will perform the lookup at template rendering.
Any ideas on how this might be done?
-e |
|
|
|
|
host Posts:93
 |
| 04/27/2007 10:28 PM |
|
| I didn't realize that that's what you were trying to do. I have an idea about that. Let me consult with folks here and I'll get back to you. |
|
|
|
|
emaynard Posts:31
 |
| 04/28/2007 5:29 AM |
|
Yeah, I think that would be a good thing to consider.
I mean almost anyone using the SQL option list against a Core table is going to need the capability unless the field is not visible in a display template.
-e |
|
|
|
|
host Posts:93
 |
| 04/30/2007 9:38 AM |
|
Ok, just for you Eric (and anyone else interested in the functionality) build 4.5.9 is available for download.
We changed the Sql List Option Builder to allow the display field to be different than the value field. WHen you install your module, you should see a Field Tag {FriendlyFIELDNAME}. This will look up and display the display field where the value field is equal to the current value.
For instance. If you create a user list from the users table for field TheUser, UserID = list item value, username = list item display then tag of {FriendlyTheUser} will return the Username of the UserID currently stored in TheUser field.
Here's the Caveat...overuse of these tags will impact portal performance, as it makes a DB call for each record. We will continue to work on optimizing, but try it out and make sure it's working the way it should.
This is also only available to the SQL List Option at this point.
Let me know how it oges.
Brian |
|
|
|
|
emaynard Posts:31
 |
| 04/30/2007 8:56 PM |
|
Posted By host on 04/30/2007 9:38 AM Ok, just for you Eric (and anyone else interested in the functionality) build 4.5.9 is available for download. We changed the Sql List Option Builder to allow the display field to be different than the value field. WHen you install your module, you should see a Field Tag {FriendlyFIELDNAME}. This will look up and display the display field where the value field is equal to the current value. Awesome! :w00t: Here's the Caveat...overuse of these tags will impact portal performance, as it makes a DB call for each record. We will continue to work on optimizing, but try it out and make sure it's working the way it should.
Understood. I'm not sure if there is anyway not to hit the DB for each record. I'll test and give you some feedback. Thanks, -eric |
|
|
|
|
emaynard Posts:31
 |
| 05/02/2007 9:39 PM |
|
Ok, Finally had a chance to test this and as far as I can tell everything looks pretty good. Performance seemed fine, but I'm sure that the more you add the worse it might get.
I would like to see this added to the Display template as well. I think the Add_xxxx template works fine the way it is.
I was able to make it work in the Display by adding the following to the Display_xxxxxx.ascx.vb file under the DisplayInfo function:
If InStr(DisplayInfo, "{friendlyTheUser}", CompareMethod.Text) <> 0 Then Dim myCStr As String = Config.GetConnectionString Dim oconnection As New SqlClient.SqlConnection(myCStr) oconnection.Open() Dim oCommand As New SqlClient.SqlCommand("Select DisplayName from vw_Users where [UserId]=" & objemt_UserAwardsrcd.RecipientID & ";", oconnection) Dim oDataReader As SqlClient.SqlDataReader = oCommand.ExecuteReader(CommandBehavior.CloseConnection) While oDataReader.Read() DisplayInfo = TagReplacement(DisplayInfo, "{friendlyTheUser}", "", oDataReader("DisplayName")) End While End If
Pretty much cut-n-paste from the View module version with a object name change.
Thanks, -eric |
|
|
|
|
rickwp Posts:20
 |
| 01/07/2008 11:29 PM |
|
I don't see any tags for field names that look like {friendlyXXX}, and if I type it manually it will actually output the tag instead of the field text. How again is this implemented? I have the list set up to draw from the table when building the list and it works fine in giving a drop down list when adding or editing a record, but I still don't see any way to display a friendly name without modifying the code that the module builder creates, and I don't want to have to go in and modify the code every time I recreate the module. How do I use this friendly name tag? Where is it found? Do I have to do something else in the form to make it work? This tag doesn't work in any of the module created by module builder. Rick |
|
|
|
|
rickwp Posts:20
 |
| 01/07/2008 11:56 PM |
|
| Also, is there a way to sort the field on the friendly name instead of the id field? |
|
|
|
|
host Posts:93
 |
| 01/08/2008 7:44 AM |
|
| If you've selected a different display field and value field in the Sql List Option Builder the {FriendlyFieldName tags are created. Since you weren't able to connect to your Sql server (from another post) how were you able to use the Sql List Option Builder? |
|
|
|
|
rickwp Posts:20
 |
| 01/08/2008 4:17 PM |
|
I have access to three web hosts right now, and one of them did allow remote connect to the sql server. I was able to place the database table in a database it really shouldn't be in. I can use this temporarily, but will need to delete the table at some point in time since it is not part of that website or project. Being able to connect to a localhost SQL Express DNN database will still be needed in the future if there is a way to do that while continuing work on this current project/module. I was able to get the friendly name to appear in displays. I wasn't able to sort on the friendly name. Is there a way to do that? |
|
|
|
|
host Posts:93
 |
| 01/08/2008 4:23 PM |
|
| There is no way to sort by them at this point, as it's a seperate database call. |
|
|
|
|