[Users] Question on multiple filters for a LayerContainer control
Ryan Williams
rwilliams at paqinteractive.com
Wed Sep 1 16:59:13 CEST 2010
We had a similar challenge here, one of our web programmers helped me
figure this out.
In this situation, I wanted all layers with a name that did NOT include
"Balance", "Ratio", or "Highlight" to appear in this layercontainer:
loader: {
filter: function(record) {
var myarr = new Array();
myarr[0]=record.get("layer").name.indexOf("Balance");
myarr[1]=record.get("layer").name.indexOf("Ratio");
myarr[2]=record.get("layer").name.indexOf("Highlight");
if(myarr[0]==-1 && myarr[1]==-1 &&
myarr[2]==-1){
return true;
}else{
return false;
}
}
Not sure if it's THE best solution, but it does work and it's fairly
simple to add additional words to search for.
Hope this helps,
Ryan
On 9/1/2010 9:49 AM, Andrew Stewart wrote:
> I am faily new to GeoExt and openlayers. What I am trying to do is add
> multiple filters to a layercontainer so that I can add multiple layers
> to each group. Not sure if this is the best way to do this but what I
> want to do is add all my Street Labels to a group called "Labels" I
> can add one no problem called Overview Streets with the following
> code, but I need to add additional layers like one called Quadrant
> Streets. When I try to modify the filter code to add additional names
> it doesn't work and I get javascript errors. Any help appreciated!
> //Define Layer List Control - Tree Control for Legend Control
> var layerList_Labels = new GeoExt.tree.LayerContainer({
> text: 'Labels',
> layerStore: mapPanel.layers,
> leaf: false,
> expanded: false,
> loader: {
> filter: function(record) {
> return record.get("layer").name.indexOf("Overview Streets") !==
> -1 (need to add Quadrant Streets here also)
> }
> }
> });
>
> ------------------------------------------------------------------------
> This e-mail is intended for the original recipient(s) only. If you
> have received it in error, please advise the sender and delete this
> message.
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
--
Ryan Williams, GISP
GIS Analyst / Programmer
PAQ Interactive Inc.
107 S State St., Suite 300
Monticello, IL 61856-1968
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100901/3a09a8b5/attachment.htm
More information about the Users
mailing list