JSDataSet.sort() syntax

Questions, tips and tricks and techniques for scripting in Servoy

JSDataSet.sort() syntax

Postby maurice » Tue Oct 19, 2010 12:35 pm

Hi,

I have a question about sorting a dataset.
it would be nice if we could use the following syntax;

myDataSet.sort(["myColumn"], true) instead of myDataSet.sort(2,true),

Because when you need to change the sql, you need to check if the dataset is still sorted on the proper column!

Any suggestions?

Thanks in advance.
Maurice Meijer
Stb Zorg
SAN Partner

Stb Zorg - http://www.stb.nl
User avatar
maurice
 
Posts: 25
Joined: Fri Sep 12, 2008 8:29 am

Re: JSDataSet.sort() syntax

Postby mboegem » Tue Oct 19, 2010 1:20 pm

Hi Maurice,

changing the SQL can still be a problem when you remove the referenced column from your SQL.

I think you can almost build this yourself.
I you write a global function where you determine the index based on a given dataset & colname you can use the returned index to sort the dataset.

Agree: not completely how you would like it, but very workable...

Code: Select all
function getDatasetColumnIndex($ds, $colName)
    {
        var $index = -1
        for (var i = 1; i <= $ds.getMaxColumnIndex(); i++)
        {
            if($ds.getColumnName(i) == $colName) $index = i;
            if($index > -1) break;
        }
       
        return $index;
    }
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: JSDataSet.sort() syntax

Postby maurice » Wed Oct 20, 2010 9:13 am

Hi Marc,

Thanks for your solution! It would be nice if Servoy could make it standard functionality.
Maurice Meijer
Stb Zorg
SAN Partner

Stb Zorg - http://www.stb.nl
User avatar
maurice
 
Posts: 25
Joined: Fri Sep 12, 2008 8:29 am

Re: JSDataSet.sort() syntax

Postby jcompagner » Wed Oct 20, 2010 10:48 am

please file a case.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: JSDataSet.sort() syntax

Postby maurice » Wed Oct 20, 2010 11:45 am

Case filed: 329018
Maurice Meijer
Stb Zorg
SAN Partner

Stb Zorg - http://www.stb.nl
User avatar
maurice
 
Posts: 25
Joined: Fri Sep 12, 2008 8:29 am


Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests

cron