Page 1 of 1

Sort on column header click

Posted: Tue Dec 20, 2005 12:51 am
by Jeff Barnes
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 ListBox

Posted: Tue Dec 20, 2005 3:41 am
by Colin Haig
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

Posted: Tue Dec 20, 2005 8:19 pm
by Jeff Barnes
Thanks Colin,

That pointed me in the right direction :-)


Jeff