Monday, December 18, 2017  
You are here:  Products * DNN KickStart * DNN KickStart Manual * Tips and Tricks * Lookup fields Register  Login
How to use localized data within lookup fields


In this case we want to try to create a module that will show data in a lookup box.
The data in the lookup box should be localized.
This means that for every locale defined (en, fr, nl) the data is shown for the locale the portal is presented in.

Download case
DNN KickStart module definitions for this case can be downloaded from the
downloads page.


Building blocks

  • Create secondary (lookup) module with localized data to lookin
  • Create primary module with lookup field to lookup data
  • Modify the primary sql and code to enable dynamic retrieval of data
  • Create a new stored procedure to lookup data with a locale parameter field
  • Modify the stored procedure to check if locale field exists
  • Return the data to the primary module

Create lookup module

Create main module

 

Create a lookup field

That will look like this in the module:

New stored procedure
Create a new stored procedure to retrieve the data from the lookup field based on a parameter filled with the locale.

We have to use a trick called:
Select statement with dynamic columns based on data content.

More inside information can be found on this site about this topic.

Check if locale field exists

More inside information can be found on this site about this topic.

Modify DataProvider

Search in your dataprovider file for this function and add this text:

#Region "Lookup data providers"

MustOverride Function myContactsLookupmyGroupItemItemCode() As IDataReader

#End Region

new text:

#Region "Lookup data providers"

Public MustOverride Function myContactsLookupmyGroupItemItemCode() As IDataReader
Public MustOverride Function myContactsLookupmyGroupItemItemCode(ByVal lanCode As String) As IDataReader

#End Region

Change ModuleController

add this function to your moduleController file (a modified copy of the existing one): 

Public Function myContactsLookupmyGroupItemItemCode(ByVal lanCode As String) As ArrayList

Dim infoList As ArrayList = Nothing
Dim idr As IDataReader = Nothing

Try

   idr = DataProvider.Instance().myContactsLookupmyGroupItemItemCode(lanCode)
   infoList = CBO.FillCollection(idr,
GetType(myContactsLookupmyGroupItemItemCodeInfo))

Finally

If Not idr Is Nothing Then

   idr.Close()
   idr.Dispose()
   idr =
Nothing

End If

End Try

Return infoList

End Function

text

 

Modify SQLDataProvider

Add the new function also to the dataProvider module:

 

#Region "Lookup data providers"

Public Overrides Function myContactsLookupmyGroupItemItemCode() As IDataReader

Return SqlHelper.ExecuteReader(ConnectionString, GetFullyQualifiedName("myContactsLookupmyGroupItemItemCode"))

End Function

 

Add the new function also to the dataProvider module:

 

#Region "Lookup data providers"

Public Overrides Function myContactsLookupmyGroupItemItemCode() As IDataReader

Return SqlHelper.ExecuteReader(ConnectionString, GetFullyQualifiedName("myContactsLookupmyGroupItemItemCode"))

End Function

Public Overrides Function myContactsLookupmyGroupItemItemCode(ByVal lanCode As String) As IDataReader

Return SqlHelper.ExecuteReader(ConnectionString, GetFullyQualifiedName("myContactsLookupmyGroupItemItemCodeByLanCode", lanCode))

End Function

#End Region

Modify SQL Creation script

Add this stored procedure:

 

create procedure {databaseOwner}[{objectQualifier}FRENTONLINE_myContactsLookupmyGroupItemItemCodeByLanCode]

@LanCode char

as

select

Item,

ItemCode

from {objectQualifier}FRENTONLINE_myGroup

where LanCode = @LanCode

GO

 

This concludes the stored procedures


 
Home  |  Company  |  Products  |  Contact  |  Downloads  |  Knowledge base
Copyright (c) 2017 FRENT IT   |  Privacy Statement  |  Terms Of Use