Re: [Gambas-user] How to sort a TableView?

2016-04-05 Thread T Lee Davidson
Oops. Good catch. Thank you for pointing that out.

Fixed.


On 04/05/2016 04:46 PM, Gianluigi wrote:
> Lee look what you made a mistake:
> (no TableView1 but GridView1)
> ValueSorted.Sort(IIf(GridView1.Columns.Ascending, gb.Ascent, gb.Descent))
>
> Ciao
> Gianluigi

-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-04-05 Thread Gianluigi
Lee look what you made a mistake:
(no TableView1 but GridView1)
ValueSorted.Sort(IIf(GridView1.Columns.Ascending, gb.Ascent, gb.Descent))

Ciao
Gianluigi

2016-04-05 20:11 GMT+02:00 T Lee Davidson :

> Yes, I agree since the Mode for String[].Sort is integer and
> GridView.Columns.Ascending is boolean.
>
> But, how about this?
> ValueSorted.Sort(IIf(TableView1.Columns.Ascending, gb.Ascent, gb.Descent))
>
>
> On 04/05/2016 10:17 AM, Gianluigi wrote:
> > Hello Lee,
> > Milio propose this change to avoid the arrows appear upside than sorting.
> > Instead of:
> > ValueSorted.Sort(GridView1.Columns.Ascending)
> > this code:
> > If GridView1.Columns.Ascending Then
> >ValueSorted.Sort(gb.Ascent)
> > Else
> >ValueSorted.Sort(gb.Descent)
> > Endif
> > Regards
> > Gianluigi
> >
>
> --
> Lee
> __
>
> "Artificial Intelligence is no match for natural stupidity."
>
>
> --
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-04-05 Thread Gianluigi
OK is the same

2016-04-05 20:11 GMT+02:00 T Lee Davidson :

> Yes, I agree since the Mode for String[].Sort is integer and
> GridView.Columns.Ascending is boolean.
>
> But, how about this?
> ValueSorted.Sort(IIf(TableView1.Columns.Ascending, gb.Ascent, gb.Descent))
>
>
> On 04/05/2016 10:17 AM, Gianluigi wrote:
> > Hello Lee,
> > Milio propose this change to avoid the arrows appear upside than sorting.
> > Instead of:
> > ValueSorted.Sort(GridView1.Columns.Ascending)
> > this code:
> > If GridView1.Columns.Ascending Then
> >ValueSorted.Sort(gb.Ascent)
> > Else
> >ValueSorted.Sort(gb.Descent)
> > Endif
> > Regards
> > Gianluigi
> >
>
> --
> Lee
> __
>
> "Artificial Intelligence is no match for natural stupidity."
>
>
> --
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-04-05 Thread T Lee Davidson
Yes, I agree since the Mode for String[].Sort is integer and 
GridView.Columns.Ascending is boolean.

But, how about this?
ValueSorted.Sort(IIf(TableView1.Columns.Ascending, gb.Ascent, gb.Descent))


On 04/05/2016 10:17 AM, Gianluigi wrote:
> Hello Lee,
> Milio propose this change to avoid the arrows appear upside than sorting.
> Instead of:
> ValueSorted.Sort(GridView1.Columns.Ascending)
> this code:
> If GridView1.Columns.Ascending Then
>ValueSorted.Sort(gb.Ascent)
> Else
>ValueSorted.Sort(gb.Descent)
> Endif
> Regards
> Gianluigi
>

-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-04-05 Thread Gianluigi
Hello Lee,
Milio propose this change to avoid the arrows appear upside than sorting.
Instead of:
ValueSorted.Sort(GridView1.Columns.Ascending)
this code:
If GridView1.Columns.Ascending Then
  ValueSorted.Sort(gb.Ascent)
Else
  ValueSorted.Sort(gb.Descent)
Endif
Regards
Gianluigi


2016-04-01 10:32 GMT+02:00 Gianluigi :

> Hello Lee,
> thank you (also from my teacher Milio :-) ), all is a perfect explanation.
>
> Regards
> Gianluigi
>
> 2016-04-01 2:21 GMT+02:00 T Lee Davidson :
>
>> That's exactly what I needed, Gianluigi. Thank you.
>>
>> It works well even preserving distinct rows with duplicate key values.
>>
>> I added a few comments to your code and added it as an example to
>> http://gambaswiki.org/wiki/comp/gb.qt4/gridview/sorted. (I
>> hope that's okay with you. If not, please let me know and I'll modify or
>> remove it.)
>>
>>
>> --
>> Lee
>> __
>>
>> "Artificial Intelligence is no match for natural stupidity."
>>
>>
>> On 03/31/2016 04:51 AM, Gianluigi wrote:
>> > Without using the database, have taught me so:
>> >
>> > Public Sub TableView1_Sort()
>> > Dim Values, ValueSorted As New String[]
>> > Dim Nx, iNx As Integer
>> > Dim tmp As String
>> >
>> >  For Nx = 0 To TableView1.Rows.Max
>> >Values.Add(TableView1[Nx, TableView1.Columns.Sort].Text)
>> >  Next
>> >  ValueSorted = Values.Copy()
>> >  ValueSorted.Sort(TableView1.Columns.Ascending)
>> >  For Nx = 0 To ValueSorted.Max
>> >For iNx = 0 To TableView1.Columns.Max
>> >  Swap TableView1[Nx, iNx].Text,
>> > TableView1[Values.Find(ValueSorted[Nx], 0, Nx), iNx].Text
>> >Next
>> >Values.Clear()
>> >For iNx = 0 To TableView1.Rows.Max
>> >  Values.Add(TableView1[iNx, TableView1.Columns.Sort].Text)
>> >Next
>> >  Next
>> >  TableView1.Refresh()
>> > End
>> >
>> > Regards
>> > Gianluigi
>>
>>
>> --
>> Transform Data into Opportunity.
>> Accelerate data analysis in your applications with
>> Intel Data Analytics Acceleration Library.
>> Click to learn more.
>> http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>
--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-04-01 Thread Gianluigi
Hello Lee,
thank you (also from my teacher Milio :-) ), all is a perfect explanation.

Regards
Gianluigi

2016-04-01 2:21 GMT+02:00 T Lee Davidson :

> That's exactly what I needed, Gianluigi. Thank you.
>
> It works well even preserving distinct rows with duplicate key values.
>
> I added a few comments to your code and added it as an example to
> http://gambaswiki.org/wiki/comp/gb.qt4/gridview/sorted. (I
> hope that's okay with you. If not, please let me know and I'll modify or
> remove it.)
>
>
> --
> Lee
> __
>
> "Artificial Intelligence is no match for natural stupidity."
>
>
> On 03/31/2016 04:51 AM, Gianluigi wrote:
> > Without using the database, have taught me so:
> >
> > Public Sub TableView1_Sort()
> > Dim Values, ValueSorted As New String[]
> > Dim Nx, iNx As Integer
> > Dim tmp As String
> >
> >  For Nx = 0 To TableView1.Rows.Max
> >Values.Add(TableView1[Nx, TableView1.Columns.Sort].Text)
> >  Next
> >  ValueSorted = Values.Copy()
> >  ValueSorted.Sort(TableView1.Columns.Ascending)
> >  For Nx = 0 To ValueSorted.Max
> >For iNx = 0 To TableView1.Columns.Max
> >  Swap TableView1[Nx, iNx].Text,
> > TableView1[Values.Find(ValueSorted[Nx], 0, Nx), iNx].Text
> >Next
> >Values.Clear()
> >For iNx = 0 To TableView1.Rows.Max
> >  Values.Add(TableView1[iNx, TableView1.Columns.Sort].Text)
> >Next
> >  Next
> >  TableView1.Refresh()
> > End
> >
> > Regards
> > Gianluigi
>
>
> --
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-03-31 Thread T Lee Davidson
That's exactly what I needed, Gianluigi. Thank you.

It works well even preserving distinct rows with duplicate key values.

I added a few comments to your code and added it as an example to 
http://gambaswiki.org/wiki/comp/gb.qt4/gridview/sorted. (I 
hope that's okay with you. If not, please let me know and I'll modify or remove 
it.)


-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."


On 03/31/2016 04:51 AM, Gianluigi wrote:
> Without using the database, have taught me so:
>
> Public Sub TableView1_Sort()
> Dim Values, ValueSorted As New String[]
> Dim Nx, iNx As Integer
> Dim tmp As String
>
>  For Nx = 0 To TableView1.Rows.Max
>Values.Add(TableView1[Nx, TableView1.Columns.Sort].Text)
>  Next
>  ValueSorted = Values.Copy()
>  ValueSorted.Sort(TableView1.Columns.Ascending)
>  For Nx = 0 To ValueSorted.Max
>For iNx = 0 To TableView1.Columns.Max
>  Swap TableView1[Nx, iNx].Text,
> TableView1[Values.Find(ValueSorted[Nx], 0, Nx), iNx].Text
>Next
>Values.Clear()
>For iNx = 0 To TableView1.Rows.Max
>  Values.Add(TableView1[iNx, TableView1.Columns.Sort].Text)
>Next
>  Next
>  TableView1.Refresh()
> End
>
> Regards
> Gianluigi

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-03-31 Thread T Lee Davidson
Thank you, Frank.

That is an interesting example. It uses an array of variant arrays as the 
underlying data-store similar to what I had done in 
the past with objects. And, they extend Object[] with a custom sort routine. 
Neat.


On 03/31/2016 02:55 AM, Frank wrote:
> Hi TLD, I found something that might help:
>
> I have put the whole code here but the bit you talk about start at line 76.
>
> found it here:http://gambas-buch.de/dw/doku.php?id=k17:k17.7:k17.7.4:start

-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-03-30 Thread T Lee Davidson
Thank you for your effort, Gianluigi. But, I am not using a database; just a 
TableView of data.

When a TableView's Sorted property is set to True, clicking on a column header 
toggles the sort indicator and raises the 
TableView's Sort event.

I need to sort the TableView rows based on the values in whichever column the 
header was clicked.


On 03/30/2016 06:06 PM, Gianluigi wrote:
> Not sure if I understand the question, but something like that, could help?
>
> If TableView1.Columns.Ascending Then
>sMySql = "SELECT *"
>sMySql &= " FROM customers"
>sMySql &= " ORDER BY surname ASC,"
>sMySql &= " name ASC"
>sMySql &= ";"
> Else
>sMySql = "SELECT *"
>sMySql &= " FROM customers"
>sMySql &= " ORDER BY surname DESC,"
>sMySql &= " name DESC"
>sMySql &= ";"
> Endif
>
> Regards
> Gianluigi
>
> 2016-03-30 22:18 GMT+02:00 T Lee Davidson :
>
>> The documentation for TableView shows a Sorted property which says,
>> "Sorting the data is not done automatically. It must be done
>> by user code." But, the page does not give any clues regarding how to
>> accomplish that. Though, obviously, sorting should be done
>> in the Sort event handler.
>>
>> In the past, I have used an array of objects to store the data represented
>> in the TableView. This provided use of Object[].Sort
>> with the _compare function.
>>
>> This time around, I am attempting to eliminate the redundancy of duplicate
>> data containers (store and view) and the cumbersome
>> syncing of the data and the view. (Perhaps I should just simply use a
>> SQLite DB and a DataView?)
>>
>> There appears to be no TableView/GridView or GridView.Columns Sort method.
>>
>> Does anyone have any hints as to how to sort a TableView?
>>
>>
>> --
>> Lee
>> __
>>
>> "Artificial Intelligence is no match for natural stupidity."
>>
>>
>> --
>> Transform Data into Opportunity.
>> Accelerate data analysis in your applications with
>> Intel Data Analytics Acceleration Library.
>> Click to learn more.
>> http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
>> ___
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
> --
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>

-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] How to sort a TableView?

2016-03-30 Thread Gianluigi
Not sure if I understand the question, but something like that, could help?

If TableView1.Columns.Ascending Then
  sMySql = "SELECT *"
  sMySql &= " FROM customers"
  sMySql &= " ORDER BY surname ASC,"
  sMySql &= " name ASC"
  sMySql &= ";"
Else
  sMySql = "SELECT *"
  sMySql &= " FROM customers"
  sMySql &= " ORDER BY surname DESC,"
  sMySql &= " name DESC"
  sMySql &= ";"
Endif

Regards
Gianluigi

2016-03-30 22:18 GMT+02:00 T Lee Davidson :

> The documentation for TableView shows a Sorted property which says,
> "Sorting the data is not done automatically. It must be done
> by user code." But, the page does not give any clues regarding how to
> accomplish that. Though, obviously, sorting should be done
> in the Sort event handler.
>
> In the past, I have used an array of objects to store the data represented
> in the TableView. This provided use of Object[].Sort
> with the _compare function.
>
> This time around, I am attempting to eliminate the redundancy of duplicate
> data containers (store and view) and the cumbersome
> syncing of the data and the view. (Perhaps I should just simply use a
> SQLite DB and a DataView?)
>
> There appears to be no TableView/GridView or GridView.Columns Sort method.
>
> Does anyone have any hints as to how to sort a TableView?
>
>
> --
> Lee
> __
>
> "Artificial Intelligence is no match for natural stupidity."
>
>
> --
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
> ___
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] How to sort a TableView?

2016-03-30 Thread T Lee Davidson
The documentation for TableView shows a Sorted property which says, "Sorting 
the data is not done automatically. It must be done 
by user code." But, the page does not give any clues regarding how to 
accomplish that. Though, obviously, sorting should be done 
in the Sort event handler.

In the past, I have used an array of objects to store the data represented in 
the TableView. This provided use of Object[].Sort 
with the _compare function.

This time around, I am attempting to eliminate the redundancy of duplicate data 
containers (store and view) and the cumbersome 
syncing of the data and the view. (Perhaps I should just simply use a SQLite DB 
and a DataView?)

There appears to be no TableView/GridView or GridView.Columns Sort method.

Does anyone have any hints as to how to sort a TableView?


-- 
Lee
__

"Artificial Intelligence is no match for natural stupidity."

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471=/4140
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user