This topic is locked
[SOLVED]

 Code example for list events

8/5/2010 9:02:49 AM
ASPRunnerPro General questions
L
luic author

Can you provide me the examples on how to apply the follow events?
a) ListGetRowCount

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14930&image=1&table=forumtopics' class='bbc_emoticon' alt='B)' /> ListQuery

c) ListFetchArray
I need application code examples and what are the usages.
Thanks.
Chris.

A
ann 8/6/2010

Chris,
all three function are used in conjunction with each other.

  1. ListQuery - used if you want to change the SQL query from the Edit SQL Query tab.

    Here is a sample from calendar template:



dim data, CalArray,newdate,listSQL

doAssignment ListOrderBy,orderBy

doAssignment ListHowOrderBy,howOrderBy

set CalArray = CreateObject("Scripting.Dictionary")

listSQL="select Field1, Field2, Field3 from TableName"

set data = CustomQuery(listSQL)

count = 0

while not data.eof

set CalArray(count) = CreateObject("Scripting.Dictionary")

CalArray(count)("Field1")=data("Field1")

CalArray(count)("Field2")=data("Field2")

CalArray(count)("Field3")=data("Field3")

count=count+1

data.MoveNext

wend

usort CalArray,"arr_sort"

data.close

doAssignment ListQuery,CalArray

end function
function arr_sort(a,<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=51686&image=1&table=forumreplies' class='bbc_emoticon' alt='B)' />

for each keys in ListOrderBy.keys

orderfield=GetFieldByIndex(ListOrderBy(keys),strTableName)

howorder=ListHowOrderBy(keys)

if a(orderfield)<>b(orderfield) then

if a(orderfield)>b(orderfield) then

if howorder="ASC" then

arr_sort = 1

exit function

else

arr_sort = -1

exit function

end if

else

if howorder="ASC" then

arr_sort = -1

exit function

else

arr_sort = 1

exit function

end if

end if

end if

next

arr_sort = 0



2) ListFetchArray - fetches records from given array.

Here is a sample code:

doAssignment ListFetchArray,asp_array_shift(rs)



3) ListGetRowCount - used to re-define number of records to display on the page.

Here is a sample:

dim dal_table, data, count

set dal_table=dal.Table("TableName")

set data = dal_table.QueryAll()

count = 0

while not data.eof

count=count+1

data.MoveNext

wend

data.close

ListGetRowCount=count
L
luic author 8/9/2010

Thanks for your example code. However, I can't figure under what circumstances I need to add custom code in these events. Can you use Car/Make application to illustrate what is the business use case I need to add custom code to these events?
Chris.

A
ann 8/10/2010

Chris,
you can check how it works here (Daily tab):

http://xlinesoft.com/templates/calendar/livedemo.htm