List - getSelectedItems()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

List - getSelectedItems()

S, Mohamed Raffi (Mohamed)

Hi,
    The SelectionManager of the List object captures the order of the
selection also.
When I get the selected Items, I get the items in the order of selection,
not in the order of Index.

In some scenario this is good, but this creates problem in some scenario.
I need to provide Up and Down button actions for a List Object.

Let's say I have 3 Objects:
0 - Zero
1 - One
2 - Two

If I select (2 - Two) first and (1 - One) next, and perform "Up" action,
I get the selected Items and iterate through.
First I get (2 - Two) item, when I move one index up, the result List
becomes
0 - Zero
2 - Two
1 - One

Next I get (1 - One) item, when I move one index up, the result List becomes
the original.
0 - Zero
1 - One
2 - Two

Is there a way to turn off that feature of retaining the order of selection
and
get the selected Items by the index?

Thanks,
Raffi

--
View this message in context: http://www.nabble.com/List---getSelectedItems%28%29-tp18688055p18688055.html
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: List - getSelectedItems()

Mr. Hericus
Hi Raffi,

I know Lists and Tables are different, but here's the approach I use for
doing the same thing with a Table.  Essentially, I iterate the selection
to create my own list of "selected indexes", and then manipulate that,
finally re-selecting the new positions based on their new indexes:

moveStepDown : function(ev){
        var smodel = this.buildsteps_table.getSelectionModel();
        var steps = this.dataObject.getSteps();
        var selection = [];
        smodel.iterateSelection(function(index) {                  
                selection.push(index);              
        }, this );                          
        if(selection.length === 0 || selection[ selection.length - 1] ===
(steps.length - 1) ){
                return;
        }
        smodel.clearSelection();  
        for(var i = selection.length - 1; i >= 0; i--){
                var tmp = steps[ selection[i] + 1 ];
                steps[ selection[i] + 1 ] = steps[ selection[i] ];
                steps[ selection[i] ] = tmp;
        }
        for(var i = 0, l = steps.length; i < l; i++){
                steps[i].setOrderas( i );
        }

        this.redisplayBuildStepsTable();
        for(var i = 0, l = selection.length; i < l; i++){
                smodel.addSelectionInterval( selection[i] + 1, selection[i] + 1);
        }                                                                             },

Sincerely,

Mr. Hericus
[hidden email]
http://www.hericus.com/


On Mon, 2008-07-28 at 04:01 -0700, raffimd wrote:

> Hi,
>     The SelectionManager of the List object captures the order of the
> selection also.
> When I get the selected Items, I get the items in the order of selection,
> not in the order of Index.
>
> In some scenario this is good, but this creates problem in some scenario.
> I need to provide Up and Down button actions for a List Object.
>
> Let's say I have 3 Objects:
> 0 - Zero
> 1 - One
> 2 - Two
>
> If I select (2 - Two) first and (1 - One) next, and perform "Up" action,
> I get the selected Items and iterate through.
> First I get (2 - Two) item, when I move one index up, the result List
> becomes
> 0 - Zero
> 2 - Two
> 1 - One
>
> Next I get (1 - One) item, when I move one index up, the result List becomes
> the original.
> 0 - Zero
> 1 - One
> 2 - Two
>
> Is there a way to turn off that feature of retaining the order of selection
> and
> get the selected Items by the index?
>
> Thanks,
> Raffi
>



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: List - getSelectedItems()

S, Mohamed Raffi (Mohamed)
Hi Hericus,
        Thanks for the suggestion. I'll do the same.
Regards,
Raffi

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Mr.
Hericus
Sent: Monday, July 28, 2008 6:18 PM
To: qooxdoo Development
Subject: Re: [qooxdoo-devel] List - getSelectedItems()

Hi Raffi,

I know Lists and Tables are different, but here's the approach I use for
doing the same thing with a Table.  Essentially, I iterate the selection
to create my own list of "selected indexes", and then manipulate that,
finally re-selecting the new positions based on their new indexes:

moveStepDown : function(ev){
        var smodel = this.buildsteps_table.getSelectionModel();
        var steps = this.dataObject.getSteps();
        var selection = [];
        smodel.iterateSelection(function(index) {                  
                selection.push(index);              
        }, this );                          
        if(selection.length === 0 || selection[ selection.length - 1]
=== (steps.length - 1) ){
                return;
        }
        smodel.clearSelection();  
        for(var i = selection.length - 1; i >= 0; i--){
                var tmp = steps[ selection[i] + 1 ];
                steps[ selection[i] + 1 ] = steps[ selection[i] ];
                steps[ selection[i] ] = tmp;
        }
        for(var i = 0, l = steps.length; i < l; i++){
                steps[i].setOrderas( i );
        }

        this.redisplayBuildStepsTable();
        for(var i = 0, l = selection.length; i < l; i++){
                smodel.addSelectionInterval( selection[i] + 1,
selection[i] + 1);
        }
},

Sincerely,

Mr. Hericus
[hidden email]
http://www.hericus.com/


On Mon, 2008-07-28 at 04:01 -0700, raffimd wrote:
> Hi,
>     The SelectionManager of the List object captures the order of the
> selection also.
> When I get the selected Items, I get the items in the order of
> selection, not in the order of Index.
>
> In some scenario this is good, but this creates problem in some
scenario.

> I need to provide Up and Down button actions for a List Object.
>
> Let's say I have 3 Objects:
> 0 - Zero
> 1 - One
> 2 - Two
>
> If I select (2 - Two) first and (1 - One) next, and perform "Up"
> action, I get the selected Items and iterate through.
> First I get (2 - Two) item, when I move one index up, the result List
> becomes 0 - Zero
> 2 - Two
> 1 - One
>
> Next I get (1 - One) item, when I move one index up, the result List
> becomes the original.
> 0 - Zero
> 1 - One
> 2 - Two
>
> Is there a way to turn off that feature of retaining the order of
> selection and get the selected Items by the index?
>
> Thanks,
> Raffi
>



------------------------------------------------------------------------
-
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge Build the coolest Linux based applications with Moblin SDK &
win great prizes Grand prize is a trip for two to an Open Source event
anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel