Hi,
I have a listbox with 8 columns ... I would like to allow the user to sort the data by clicking on a column header, how can I do this?
Thanks,
Jeff
Sort on column header click
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
-
- Posts: 310
- Joined: Mon Oct 10, 2005 5:10 am
Sort on ListBox
Jeff
Use aTags
aTags := { {|| nTag := 1,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 2,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 3,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 4,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 5,'' },;
{|| nTag := 6,HeadSort(oQuote,oLbx,nTag)}}
static function HeadSort(oQuote,oLbx,nTag)
do case
case nTag == 1
oQuote:SetOrder('QUOTENO')
oQuote:Bottom()
oLbx:GoBottom()
case nTag == 2
oQuote:SetOrder('CLIENT')
oQuote:Top()
oLbx:GoTop()
case nTag == 3
oQuote:SetOrder('QDATE')
oQuote:Top()
case nTag == 4
oQuote:SetOrder('CONTACT')
oQuote:Top()
case nTag == 6
oQuote:SetOrder('PROJECT')
oQuote:Top()
endcase
oLbx:Refresh()
oLbx:SetFocus()
return(nil)
//------------------------------------------------------------------------------//
Hope this helps
Cheers
Colin
Use aTags
aTags := { {|| nTag := 1,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 2,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 3,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 4,HeadSort(oQuote,oLbx,nTag)},;
{|| nTag := 5,'' },;
{|| nTag := 6,HeadSort(oQuote,oLbx,nTag)}}
static function HeadSort(oQuote,oLbx,nTag)
do case
case nTag == 1
oQuote:SetOrder('QUOTENO')
oQuote:Bottom()
oLbx:GoBottom()
case nTag == 2
oQuote:SetOrder('CLIENT')
oQuote:Top()
oLbx:GoTop()
case nTag == 3
oQuote:SetOrder('QDATE')
oQuote:Top()
case nTag == 4
oQuote:SetOrder('CONTACT')
oQuote:Top()
case nTag == 6
oQuote:SetOrder('PROJECT')
oQuote:Top()
endcase
oLbx:Refresh()
oLbx:SetFocus()
return(nil)
//------------------------------------------------------------------------------//
Hope this helps
Cheers
Colin
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact: