stuck with qx.ui.list.List

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

stuck with qx.ui.list.List

Gregory Beaver
Hi,

when I change the model of a qx.ui.list.List like:

var list = new qx.ui.list.List(), a;
list.setModel(a = new qx.data.Array([1,2,3]));
list.setSelection(a.getItem(0));

list.setModel(new qx.data.Array([2,3,4]));

the selection remains visually on item 0.  How do I tell the list to
reset its selection, and why does this not automatically occur when the
model changes?

Thanks,
Greg

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: stuck with qx.ui.list.List

Daniel Wagner
Administrator
Hi Greg,

I tried to run your code but this line:

list.setSelection(a.getItem(0));

threw an exception because the selection expects an instance of
qx.data.Array but getItem returns a number. After replacing it with
slice(0, 1), everything works as expected:

http://tinyurl.com/ntuyyrp

FYI, the list automatically applies a default selection when the model
changes. In this case, since the selection mode isn't "one", that means
no item will be selected.

Regards,
Daniel

On 28.08.2013 21:46, Gregory Beaver wrote:

> Hi,
>
> when I change the model of a qx.ui.list.List like:
>
> var list = new qx.ui.list.List(), a;
> list.setModel(a = new qx.data.Array([1,2,3]));
> list.setSelection(a.getItem(0));
>
> list.setModel(new qx.data.Array([2,3,4]));
>
> the selection remains visually on item 0.  How do I tell the list to
> reset its selection, and why does this not automatically occur when the
> model changes?
>
> Thanks,
> Greg
>
> ------------------------------------------------------------------------------
> Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
> Discover the easy way to master current and previous Microsoft technologies
> and advance your career. Get an incredible 1,500+ hours of step-by-step
> tutorial videos with LearnDevNow. Subscribe today and save!
> http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: stuck with qx.ui.list.List

rsantiagopaz
In reply to this post by Gregory Beaver
use this Gregory
list.getSelection().push(a.getItem(0));
instead of
list.setSelection(a.getItem(0));

or list.getSelection().removeAll() for no selection
Reply | Threaded
Open this post in threaded view
|

Re: stuck with qx.ui.list.List

Loren Schlomer
Correct.  The selection model is looking for an array, not an object.   So, setSelection([a.getItem(0))]) would also work.






On Thu, Aug 29, 2013 at 11:27 AM, rsantiagopaz <[hidden email]> wrote:
use this Gregory
list.getSelection().push(a.getItem(0));
instead of
list.setSelection(a.getItem(0));

or list.getSelection().removeAll() for no selection



--
View this message in context: http://qooxdoo.678.n2.nabble.com/stuck-with-qx-ui-list-List-tp7584489p7584503.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: stuck with qx.ui.list.List

rsantiagopaz
warning, because if you use setSelection for set other arrays, if you add listeners previously (like this code below), the events lost.

var list = new qx.ui.list.List(model);

//Pre-Select "Item No 20"
list.getSelection().push(model.getItem(20));

//log selection changes
list.getSelection().addListener("change", function(e) {
  this.debug("Selection: " + list.getSelection().getItem(0));
}, this);


This is from basic qx.ui.list.List documentation
Reply | Threaded
Open this post in threaded view
|

Re: stuck with qx.ui.list.List

Loren Schlomer
Very true, and duly noted.  Always better to work with a single selection model.


On Thu, Aug 29, 2013 at 11:58 AM, rsantiagopaz <[hidden email]> wrote:
warning, because if you use setSelection for set other arrays, if you add
listeners previously (like this code below), the events lost.

var list = new qx.ui.list.List(model);

//Pre-Select "Item No 20"
list.getSelection().push(model.getItem(20));

//log selection changes
list.getSelection().addListener("change", function(e) {
  this.debug("Selection: " + list.getSelection().getItem(0));
}, this);


This is from basic qx.ui.list.List documentation



--
View this message in context: http://qooxdoo.678.n2.nabble.com/stuck-with-qx-ui-list-List-tp7584489p7584507.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel