6/6/2025 9:20:52 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
|
|
|
|
Dynamic Listview control
Posted: 27 Jun 07 10:51 AM
|
I am populating a listview with code. I can't seem to break it into columns, get the headers to work and the column I get is truncated.
Does anyone know of any sample code in SLX that dynamically populates and formats a listview, or other documentation to assist with this? Thanks |
|
|
|
Re: Dynamic Listview control
Posted: 09 Jul 07 4:22 PM
|
In 6.2 and Above I've only used predefined Columns, Items, etc. But here's the listview build code:
'Including Script - System:SLX Database Support 'Including Script - Personal:ASI_Scripts option explicit
Sub ExecSQLClosedOpps(TheType) Set newRow = lstClosedOpps.Items.Add newRow.tag = TheTYPE & "s" newRow.caption = TheTYPE & "s" g_AccountTypeFilter = " AND ac.Type = '" & g_AccountType & "' " g_AccountFilters = g_AccountTypeFilter & g_AccountUsersFilter & g_AccountDEPTSFilter
g_MonetaryAmount = 0.00 g_LaSalleDepartmentFilter = " AND p.SUPPLIER = '" & g_LasalleDefaultDepartment & "' "
strSQL = "SELECT ISNULL(Monetary_Amount,0.00) AS Total FROM ASI_Opp_Product aop, Product p, Opportunity opp, Account ac " strSQL = strSQL & " WHERE aop.ProductID = p.ProductID AND aop.OpportunityID = opp.OpportunityID AND opp.AccountID = ac.AccountID " strSQL = strSQL & g_AccountFilters & g_OppProductActualCloseDateFilter strSQL = strSQL & g_OppProdStageFilter & g_LaSalleDepartmentFilter Set RS_DB = objCon_DB.GetNewRecordSet RS_DB.Open strSQL, objCon_DB.Connection KOUNTER = 0 While Not RS_DB.EOF KOUNTER = KOUNTER + 1 g_MonetaryAmount = g_MonetaryAmount + getNumericValue(RS_DB,"Total") RS_DB.MoveNext Wend ' Col 1 newRow.SubItems.Add cSTR(KOUNTER) ' Col 2 newRow.SubItems.Add FormatCurrency(g_MonetaryAmount,0)
END SUB
SUB ExecSQLNumOfAccounts(TheTYPE) DIM TotalTotal Set newRow = lstNumOfAccounts.Items.Add newRow.tag = TheTYPE & "s" newRow.caption = TheTYPE & "s" g_AccountTypeFilter = " AND ac.Type = '" & g_AccountType & "' " g_AccountFilters = g_AccountTypeFilter & g_AccountUsersFilter & g_AccountDEPTSFilter
strSQL = "SELECT Count(ac.AccountID) AS Total FROM Account ac WHERE 1 = 1 " strSQL = strSQL & g_AccountFilters CALL AddListItemValue
CALL ExecSQLNumOfAccountsByTier("A") TOTALTOTAL= cLNG(TheValue) CALL ExecSQLNumOfAccountsByTier("B") CALL ExecSQLNumOfAccountsByTier("C")
strSQL = "SELECT Count(ac.AccountID) AS Total FROM Account ac INNER JOIN ASI_ACCT_Ext asi ON ac.AccountID = asi.AccountID " strSQL = strSQL & " WHERE asi.Rhythms_Status = 'Active Rhythms' " strSQL = strSQL & g_AccountFilters
CALL AddListItemValue
'''''the way we'll calculate No recent history is by taking total A Accounts and subtracting A Accounts WITH history,. strSQL = " select Ac.AccouNTID, Count(HISTORYID) " strSQL = strSQL & " from sysdba.account ac " strSQL = strSQL & " left outer join history h on ac.accountid = h.accountid " strSQL = strSQL & " join sysdba.ASI_ACCT_EXT asi on ac.accountid = asi.accountid " strSQL = strSQL & " where h.COMPLETEDDATE > (GETDATE() - 30) AND h.COMPLETEDDATE < (GETDATE() + 1) AND asi.Marketing_Tier = 'A' AND h.type > " & minANHtype & " and h.type < " & maxANHtype & g_AccountFilters & " " strSQL = strSQL & " group by AC.ACCOUNTID "
Set RS_DB = objCon_DB.GetNewRecordSet RS_DB.Open strSQL, objCon_DB.Connection KOUNTER = RS_DB.RecordCount TheValue = TOTALTOTAL - KOUNTER IF TheValue < 1 THEN TheValue = 0 '''''''''' MSGBOX cSTR(TheValue) & " " & cSTR(TOTALTOTAL) & " " & cSTR(KOUNTER) newRow.SubItems.Add TheValue
END SUB
Function GetValue(RecordSet, FieldName) If Not IsNull(RecordSet.Fields(FieldName)) Then GetValue = RecordSet.Fields(FieldName).Value Else GetValue = "" End If End Function
Function GetNumericValue(RecordSet, FieldName) If Not IsNull(RecordSet.Fields(FieldName)) Then GetNumericValue = cDBL(RecordSet.Fields(FieldName).Value) Else GetNumericValue = 0 End If End Function
Sub AddListItemValue Set RS_DB = objCon_DB.GetNewRecordSet RS_DB.Open strSQL, objCon_DB.Connection If Not RS_DB.EOF Then TheValue = getValue(RS_DB,"Total") newRow.SubItems.Add TheValue Application.Debug.WriteLine " The Value: " & TheValue & " SQL" & strSQL Application.Debug.WriteLine "" End If END SUB
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|