[Commits] r1260 - in core/trunk/geoext: examples lib lib/GeoExt/widgets lib/GeoExt/widgets/grid tests tests/lib/GeoExt/widgets tests/lib/GeoExt/widgets/grid
commits at geoext.org
commits at geoext.org
Wed Jul 15 10:54:04 CEST 2009
Author: elemoine
Date: 2009-07-15 10:54:04 +0200 (Wed, 15 Jul 2009)
New Revision: 1260
Added:
core/trunk/geoext/lib/GeoExt/widgets/grid/
core/trunk/geoext/lib/GeoExt/widgets/grid/FeatureSelectionModel.js
core/trunk/geoext/tests/lib/GeoExt/widgets/grid/
core/trunk/geoext/tests/lib/GeoExt/widgets/grid/FeatureSelectionModel.html
Modified:
core/trunk/geoext/examples/feature-grid.html
core/trunk/geoext/examples/feature-grid.js
core/trunk/geoext/lib/GeoExt.js
core/trunk/geoext/tests/list-tests.html
Log:
Add GeoExt.grid.FeatureSelectionModel, r=ahocevar (closes #77)
Modified: core/trunk/geoext/examples/feature-grid.html
===================================================================
--- core/trunk/geoext/examples/feature-grid.html 2009-07-15 08:49:15 UTC (rev 1259)
+++ core/trunk/geoext/examples/feature-grid.html 2009-07-15 08:54:04 UTC (rev 1260)
@@ -18,8 +18,9 @@
GeoJSON document (data/summits.json).</p>
<p>Because the layer and the store are bound to each other, the
- features loaded into the store are automatically added to the
- layer.</p>
+ features loaded into the store are automatically added to the layer. A
+ GeoExt feature selection model is also used so that selecting rows in
+ the grid selects features in the layer, and vice-versa.</p>
<p>See <a href=feature-grid.js>feature-grid.js</a>.</p>
Modified: core/trunk/geoext/examples/feature-grid.js
===================================================================
--- core/trunk/geoext/examples/feature-grid.js 2009-07-15 08:49:15 UTC (rev 1259)
+++ core/trunk/geoext/examples/feature-grid.js 2009-07-15 08:54:04 UTC (rev 1260)
@@ -64,7 +64,8 @@
header: "Elevation",
width: 100,
dataIndex: "elevation"
- }]
+ }],
+ sm: new GeoExt.grid.FeatureSelectionModel()
});
// create a panel and add the map panel and grid panel
Added: core/trunk/geoext/lib/GeoExt/widgets/grid/FeatureSelectionModel.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/grid/FeatureSelectionModel.js (rev 0)
+++ core/trunk/geoext/lib/GeoExt/widgets/grid/FeatureSelectionModel.js 2009-07-15 08:54:04 UTC (rev 1260)
@@ -0,0 +1,316 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/** api: (define)
+ * module = GeoExt.grid
+ * class = FeatureSelectionModel
+ * base_link = `Ext.grid.RowSelectionModel <http://extjs.com/deploy/dev/docs/?class=Ext.grid.RowSelectionModel>`_
+ */
+
+Ext.namespace('GeoExt.grid');
+
+/** api: constructor
+ * .. class:: FeatureSelectionModel
+ *
+ * A row selection model which enables automatic selection of features
+ * in the map when rows are selected in the grid and vice-versa.
+ */
+
+/** api: example
+ * Sample code to create a feature grid with a feature selection model:
+ *
+ * .. code-block:: javascript
+ *
+ * var gridPanel = new Ext.grid.GridPanel({
+ * title: "Feature Grid",
+ * region: "east",
+ * store: store,
+ * width: 320,
+ * columns: [{
+ * header: "Name",
+ * width: 200,
+ * dataIndex: "name"
+ * }, {
+ * header: "Elevation",
+ * width: 100,
+ * dataIndex: "elevation"
+ * }],
+ * sm: new GeoExt.grid.FeatureSelectionModel()
+ * });
+ */
+
+GeoExt.grid.FeatureSelectionModelMixin = {
+
+ /** api: config[autoActivateControl]
+ * ``Boolean`` If true the select feature control is activated and
+ * deactivated when binding and unbinding. Defaults to true.
+ */
+ autoActivateControl: true,
+
+ /** api: config[layerFromStore]
+ * ``Boolean`` If true, and if the constructor is passed neither a
+ * layer nor a select feature control, a select feature control is
+ * created using the layer found in the grid's store. Set it to
+ * false if you want to manually bind the selection model to a
+ * layer. Defaults to true.
+ */
+ layerFromStore: true,
+
+ /** api: config[selectControl]
+ *
+ * ``OpenLayers.Control.SelectFeature`` A select feature control. If not
+ * provided one will be created. If provided any "layer" config option
+ * will be ignored, and its "multiple" option will be used to configure
+ * the selectionModel. If an ``Object`` is provided here, it will be
+ * passed as config to the SelectFeature constructor, and the "layer"
+ * config option will be used for the layer.
+ */
+
+ /** private: property[selectControl]
+ * ``OpenLayers.Control.SelectFeature`` The select feature control
+ * instance.
+ */
+ selectControl: null,
+
+ /** api: config[layer]
+ * ``OpenLayers.Layer.Vector`` The vector layer used for the creation of
+ * the select feature control, it must already be added to the map. If not
+ * provided, the layer bound to the grid's store, if any, will be used.
+ */
+
+ /** private: property[bound]
+ * ``Boolean`` Flag indicating if the selection model is bound.
+ */
+ bound: false,
+
+ /** private: property[superclass]
+ * ``Ext.grid.AbstractSelectionModel`` Our superclass.
+ */
+ superclass: null,
+
+ /** private */
+ constructor: function(config) {
+ config = config || {};
+ if(config.selectControl instanceof OpenLayers.Control.SelectFeature) {
+ if(!config.singleSelect) {
+ var ctrl = config.selectControl;
+ config.singleSelect = !(ctrl.multiple || !!ctrl.multipleKey);
+ }
+ } else if(config.layer instanceof OpenLayers.Layer.Vector) {
+ this.selectControl = this.createSelectControl(
+ config.layer, config.selectControl
+ );
+ delete config.layer;
+ delete config.selectControl;
+ }
+ this.superclass = arguments.callee.superclass;
+ this.superclass.constructor.call(this, config);
+ },
+
+ /** private: method[initEvents]
+ *
+ * Called after this.grid is defined
+ */
+ initEvents: function() {
+ this.superclass.initEvents.call(this);
+ if(this.layerFromStore) {
+ var layer = this.grid.getStore() && this.grid.getStore().layer;
+ if(layer &&
+ !(this.selectControl instanceof OpenLayers.Control.SelectFeature)) {
+ this.selectControl = this.createSelectControl(
+ layer, this.selectControl
+ );
+ }
+ }
+ if(this.selectControl) {
+ this.bind(this.selectControl);
+ }
+ },
+
+ /** private: createSelectControl
+ * :param layer: ``OpenLayers.Layer.Vector`` The vector layer.
+ * :param config: ``Object`` The select feature control config.
+ *
+ * Create the select feature control.
+ */
+ createSelectControl: function(layer, config) {
+ config = config || {};
+ var singleSelect = config.singleSelect !== undefined ?
+ config.singleSelect : this.singleSelect;
+ config = OpenLayers.Util.extend({
+ toggle: true,
+ multipleKey: singleSelect ? null :
+ (Ext.isMac ? "metaKey" : "ctrlKey")
+ }, config);
+ var selectControl = new OpenLayers.Control.SelectFeature(
+ layer, config
+ );
+ layer.map.addControl(selectControl);
+ return selectControl;
+ },
+
+ /** api: method[bind]
+ *
+ * :param obj: ``OpenLayers.Layer.Vector`` or
+ * ``OpenLayers.Control.SelectFeature`` The object this selection model
+ * should be bound to, either a vector layeer or a select feature
+ * control.
+ * :param options: ``Object`` An object with a "controlConfig"
+ * property referencing the configuration object to pass to the
+ * ``OpenLayers.Control.SelectFeature`` constructor.
+ * :return: ``OpenLayers.Control.SelectFeature`` The select feature
+ * control this selection model uses.
+ *
+ * Bind the selection model to a layer or a SelectFeature control.
+ */
+ bind: function(obj, options) {
+ if(!this.bound) {
+ options = options || {};
+ this.selectControl = obj;
+ if(obj instanceof OpenLayers.Layer.Vector) {
+ this.selectControl = this.createSelectControl(
+ obj, options.controlConfig
+ );
+ }
+ if(this.autoActivateControl) {
+ this.selectControl.activate();
+ }
+ var layers = this.getLayers();
+ for(var i = 0, len = layers.length; i < len; i++) {
+ layers[i].events.on({
+ featureselected: this.featureSelected,
+ featureunselected: this.featureUnselected,
+ scope: this
+ });
+ }
+ this.on("rowselect", this.rowSelected, this);
+ this.on("rowdeselect", this.rowDeselected, this);
+ this.bound = true;
+ }
+ return this.selectControl;
+ },
+
+ /** api: method[unbind]
+ * :return: ``OpenLayers.Control.SelectFeature`` The select feature
+ * control this selection model used.
+ *
+ * Unbind the selection model from the layer or SelectFeature control.
+ */
+ unbind: function() {
+ var selectControl = this.selectControl;
+ if(this.bound) {
+ var layers = this.getLayers();
+ for(var i = 0, len = layers.length; i < len; i++) {
+ layers[i].events.un({
+ featureselected: this.featureSelected,
+ featureunselected: this.featureUnselected,
+ scope: this
+ });
+ }
+ this.un("rowselect", this.rowSelected, this);
+ this.un("rowdeselect", this.rowDeselected, this);
+ if(this.autoActivateControl) {
+ selectControl.deactivate();
+ }
+ this.selectControl = null;
+ this.bound = false;
+ }
+ return selectControl;
+ },
+
+ /** private: method[featureSelected]
+ * :param evt: ``Object`` An object with a feature property referencing
+ * the selected feature.
+ */
+ featureSelected: function(evt) {
+ if(!this._selecting) {
+ var store = this.grid.store;
+ var row = store.findBy(function(record, id) {
+ return record.data.feature == evt.feature;
+ });
+ if(row != -1 && !this.isSelected(row)) {
+ this._selecting = true;
+ this.selectRow(row, !this.singleSelect);
+ this._selecting = false;
+ // focus the row in the grid to ensure it is visible
+ this.grid.getView().focusRow(row);
+ }
+ }
+ },
+
+ /** private: method[featureUnselected]
+ * :param evt: ``Object`` An object with a feature property referencing
+ * the unselected feature.
+ */
+ featureUnselected: function(evt) {
+ if(!this._selecting) {
+ var store = this.grid.store;
+ var row = store.findBy(function(record, id) {
+ return record.data.feature == evt.feature;
+ });
+ if(row != -1 && this.isSelected(row)) {
+ this._selecting = true;
+ this.deselectRow(row);
+ this._selecting = false;
+ this.grid.getView().focusRow(row);
+ }
+ }
+ },
+
+ /** private: method[rowSelected]
+ * :param model: ``Ext.grid.RowSelectModel`` The row select model.
+ * :param row: ``Integer`` The row index.
+ * :param record: ``Ext.data.Record`` The record.
+ */
+ rowSelected: function(model, row, record) {
+ var feature = record.data.feature;
+ if(!this._selecting && feature) {
+ var layers = this.getLayers();
+ for(var i = 0, len = layers.length; i < len; i++) {
+ if(layers[i].selectedFeatures.indexOf(feature) == -1) {
+ this._selecting = true;
+ this.selectControl.select(feature);
+ this._selecting = false;
+ break;
+ }
+ }
+ }
+ },
+
+ /** private: method[rowDeselected]
+ * :param model: ``Ext.grid.RowSelectModel`` The row select model.
+ * :param row: ``Integer`` The row index.
+ * :param record: ``Ext.data.Record`` The record.
+ */
+ rowDeselected: function(model, row, record) {
+ var feature = record.data.feature;
+ if(!this._selecting && feature) {
+ var layers = this.getLayers();
+ for(var i = 0, len = layers.length; i < len; i++) {
+ if(layers[i].selectedFeatures.indexOf(feature) != -1) {
+ this._selecting = true;
+ this.selectControl.unselect(feature);
+ this._selecting = false;
+ break;
+ }
+ }
+ }
+ },
+
+ /** private: method[getLayers]
+ * Return the layers attached to the select feature control.
+ */
+ getLayers: function() {
+ return this.selectControl.layers || [this.selectControl.layer];
+ }
+};
+
+GeoExt.grid.FeatureSelectionModel = Ext.extend(
+ Ext.grid.RowSelectionModel,
+ GeoExt.grid.FeatureSelectionModelMixin
+);
Modified: core/trunk/geoext/lib/GeoExt.js
===================================================================
--- core/trunk/geoext/lib/GeoExt.js 2009-07-15 08:49:15 UTC (rev 1259)
+++ core/trunk/geoext/lib/GeoExt.js 2009-07-15 08:54:04 UTC (rev 1260)
@@ -92,7 +92,8 @@
"GeoExt/widgets/LegendImage.js",
"GeoExt/widgets/LegendWMS.js",
"GeoExt/widgets/LegendPanel.js",
- "GeoExt/widgets/ZoomSlider.js"
+ "GeoExt/widgets/ZoomSlider.js",
+ "GeoExt/widgets/grid/FeatureSelectionModel.js"
);
var agent = navigator.userAgent;
Added: core/trunk/geoext/tests/lib/GeoExt/widgets/grid/FeatureSelectionModel.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/grid/FeatureSelectionModel.html (rev 0)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/grid/FeatureSelectionModel.html 2009-07-15 08:54:04 UTC (rev 1260)
@@ -0,0 +1,376 @@
+<!DOCTYPE html>
+<html debug="true">
+ <head>
+ <script type="text/javascript" src="../../../../../../openlayers/lib/OpenLayers.js"></script>
+ <script type="text/javascript" src="../../../../../../ext/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="../../../../../../ext/ext-all-debug.js"></script>
+ <script type="text/javascript" src="../../../../../lib/GeoExt.js"></script>
+
+ <script type="text/javascript">
+
+ function test_init(t) {
+ t.plan(11);
+
+ /*
+ * Set up
+ */
+ var map, layer, layers, selectControl, store, sm;
+
+ map = new OpenLayers.Map();
+ layer = new OpenLayers.Layer.Vector("vector");
+ layers = [layer];
+ map.addLayers(layers);
+
+ store = new GeoExt.data.FeatureStore({layer: layer});
+
+ /*
+ * Test
+ */
+
+ // create a feature selection model
+ // 1 test
+ sm = new GeoExt.grid.FeatureSelectionModel();
+ t.ok(sm instanceof Ext.grid.RowSelectionModel,
+ "a feature selection model is a row selection model");
+
+ // create a feature selection model and give it a
+ // select feature control
+ // 2 tests
+ selectControl = new OpenLayers.Control.SelectFeature(layer);
+ sm = new GeoExt.grid.FeatureSelectionModel({
+ selectControl: selectControl, multiple: false
+ });
+ t.ok(sm.selectControl == selectControl,
+ "ctor sets the passed select feature control in the instance");
+ t.eq(sm.singleSelect, true,
+ "ctor sets singleSelect to true in the instance");
+
+ // create a feature selection model with singleSelect true and give
+ // it a select feature control
+ // 1 test
+ selectControl = new OpenLayers.Control.SelectFeature(layer);
+ sm = new GeoExt.grid.FeatureSelectionModel({
+ singleSelect: true,
+ selectControl: selectControl
+ });
+ t.eq(sm.selectControl.multiple, false,
+ "ctor configures the select feature control with multiple false");
+
+ // create a feature selection model and give it a layer and
+ // a select control config
+ // 3 tests
+ sm = new GeoExt.grid.FeatureSelectionModel({
+ layer: layer,
+ selectControl: {
+ hover: true
+ }
+ });
+ t.ok(sm.selectControl instanceof OpenLayers.Control.SelectFeature,
+ "ctor creates a select feature control when passed a layer");
+ t.ok(sm.selectControl.layer == layer,
+ "ctor configures the select feature control with the passed layer");
+ t.eq(sm.selectControl.hover, true,
+ "ctor configures the select feature control with the passed config");
+
+ // create a feature selection model and create a grid with it
+ // 3 tests
+ sm = new GeoExt.grid.FeatureSelectionModel({
+ selectControl: {
+ hover: true
+ }
+ });
+ var grid = new Ext.grid.GridPanel({
+ renderTo: "grid",
+ store: store,
+ columns: [{
+ header: "name"
+ }],
+ sm: sm,
+ deferRowRender: false
+ });
+ t.ok(sm.selectControl instanceof OpenLayers.Control.SelectFeature,
+ "init creates a select feature control ");
+ t.ok(sm.selectControl.layer == layer,
+ "init configures the select feature control with the store layer");
+ t.eq(sm.selectControl.hover, true,
+ "init configures the select feature control with the passed config");
+ grid.destroy();
+
+ // 1 test
+ var CheckboxSelectionModel = Ext.extend(
+ Ext.grid.CheckboxSelectionModel,
+ GeoExt.grid.FeatureSelectionModelMixin
+ );
+ sm = new CheckboxSelectionModel();
+ t.ok(sm instanceof Ext.grid.CheckboxSelectionModel,
+ "instance is a checkbox selection model");
+ }
+
+ function test_row_selection(t) {
+ t.plan(7);
+
+ /*
+ * Set up
+ */
+
+ var map, layer, features, store, sm, grid, e;
+
+ map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.Vector("vector");
+ map.addLayer(layer);
+
+ features = [
+ new OpenLayers.Feature.Vector(null,
+ {foo: "foo1", bar: "bar1"}
+ ),
+ new OpenLayers.Feature.Vector(null,
+ {foo: "foo2", bar: "bar2"}
+ )
+ ];
+
+ store = new GeoExt.data.FeatureStore({
+ layer: layer,
+ data: features
+ });
+
+ sm = new GeoExt.grid.FeatureSelectionModel();
+
+ grid = new Ext.grid.GridPanel({
+ renderTo: "grid",
+ store: store,
+ columns: [{
+ dataIndex: "foo"
+ }, {
+ dataIndex: "bar"
+ }],
+ sm: sm,
+ deferRowRender: false
+ });
+
+ /*
+ * Test
+ */
+
+ // simulate a mousedown on the first row
+ // test that the first feature is selected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: false
+ };
+ grid.fireEvent("rowmousedown", grid, 0, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[0]) > -1,
+ "click on row 0 selects feature 0");
+
+ // simulate a mousedown on the first row
+ // test that the first feature is deselected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: true
+ };
+ grid.fireEvent("rowmousedown", grid, 0, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[0]) < 0,
+ "click on row 0 deselects feature 0");
+
+ // simulate a mousedown on the second row
+ grid.fireEvent("rowmousedown", grid, 1, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[1]) > -1,
+ "click on row 1 selects feature 1");
+
+ sm.clearSelections();
+
+ // select feature 0
+ // test that the first row is selected
+ sm.selectControl.select(features[0]);
+ t.ok(sm.isSelected(0),
+ "selecting feature 0 selects row 0");
+
+ // select feature 1
+ // test that the second row is selected
+ sm.selectControl.select(features[1]);
+ t.ok(sm.isSelected(1),
+ "selecting feature 1 selects row 1");
+
+ // unselect feature 0
+ // test that the first row is selected
+ sm.selectControl.unselect(features[0]);
+ t.ok(!sm.isSelected(0),
+ "unselecting feature 0 unselects row 0");
+
+ // unselect feature 1
+ // test that the second row is unselected
+ sm.selectControl.unselect(features[1]);
+ t.ok(!sm.isSelected(1),
+ "unselecting feature 1 unselects row 1");
+
+ /*
+ * Tear down
+ */
+ grid.destroy();
+ }
+
+
+ function test_bind_unbind(t) {
+ t.plan(9);
+
+ /*
+ * Set up
+ */
+
+ var map, layer, selectControl, features, store, sm, grid, e;
+
+ map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.Vector("vector");
+ map.addLayer(layer);
+
+ selectControl = new OpenLayers.Control.SelectFeature(layer);
+ map.addControl(selectControl);
+
+ features = [
+ new OpenLayers.Feature.Vector(null,
+ {foo: "foo1", bar: "bar1"}
+ ),
+ new OpenLayers.Feature.Vector(null,
+ {foo: "foo2", bar: "bar2"}
+ )
+ ];
+
+ store = new GeoExt.data.FeatureStore({
+ layer: layer,
+ data: features
+ });
+
+ sm = new GeoExt.grid.FeatureSelectionModel({
+ layerFromStore: false
+ });
+
+ grid = new Ext.grid.GridPanel({
+ renderTo: "grid",
+ store: store,
+ columns: [{
+ dataIndex: "foo"
+ }, {
+ dataIndex: "bar"
+ }],
+ sm: sm,
+ deferRowRender: false
+ });
+
+ /*
+ * Test
+ */
+
+ // simulate a mousedown on the first row
+ // test that the first feature is not selected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: false
+ };
+ grid.fireEvent("rowmousedown", grid, 0, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[0]) < 0,
+ "click on row 0 does not select feature 0");
+ sm.clearSelections();
+
+ // select feature 0
+ // test that the first row is not selected
+ selectControl.select(features[0]);
+ t.ok(!sm.isSelected(0),
+ "selecting feature 0 does not select row 0");
+ selectControl.unselect(features[0]);
+
+ // bind the select control to the selection model
+ sm.bind(selectControl);
+
+ // simulate a mousedown on the second row
+ // test that the second feature is selected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: false
+ };
+ grid.fireEvent("rowmousedown", grid, 1, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[1]) > -1,
+ "click on row 1 selects feature 1");
+ sm.clearSelections();
+
+ // select feature 1
+ // test that the second row is selected
+ selectControl.select(features[1]);
+ t.ok(sm.isSelected(1),
+ "selecting feature 1 selects row 1");
+ selectControl.unselect(features[1]);
+ sm.clearSelections();
+
+ // unbind row and feature selection
+ sm.unbind();
+ // (side effect: selectControl is deactivated)
+
+ // simulate a mousedown on the first row
+ // test that the first feature is not selected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: false
+ };
+ grid.fireEvent("rowmousedown", grid, 0, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[0]) < 0,
+ "click on row 0 does not select feature 0");
+ sm.clearSelections();
+
+ // select feature 0
+ // test that the first row is not selected
+ selectControl.select(features[0]);
+ t.ok(!sm.isSelected(0),
+ "selecting feature 0 does not select row 0");
+ selectControl.unselect(features[0]);
+
+ // bind selection of features on a layer to rows
+ sm.bind(layer, {controlConfig: {hover: true}});
+
+ // verify that controlConfig has been applied
+ t.eq(sm.selectControl.hover, true,
+ "bind configures correctly the select feature control");
+
+ // simulate a mousedown on the second row
+ // test that the second feature is selected in the layer
+ e = {
+ button: 0,
+ shiftKey: false,
+ ctrlKey: false
+ };
+ grid.fireEvent("rowmousedown", grid, 1, e);
+ t.ok(OpenLayers.Util.indexOf(layer.selectedFeatures,
+ features[1]) > -1,
+ "click on row 1 selects feature 1");
+ sm.clearSelections();
+
+ // select feature 1
+ // test that the second row is selected
+ sm.selectControl.select(features[1]);
+ t.ok(sm.isSelected(1),
+ "selecting feature 1 selects row 1");
+ sm.selectControl.unselect(features[1]);
+ sm.clearSelections();
+
+ /*
+ * Tear down
+ */
+ grid.destroy();
+ }
+ </script>
+
+ <body>
+ <div id="map" style="width:100px;height:100px"></div>
+ <div id="grid"></div>
+ </body>
+</html>
Modified: core/trunk/geoext/tests/list-tests.html
===================================================================
--- core/trunk/geoext/tests/list-tests.html 2009-07-15 08:49:15 UTC (rev 1259)
+++ core/trunk/geoext/tests/list-tests.html 2009-07-15 08:54:04 UTC (rev 1260)
@@ -24,4 +24,5 @@
<li>lib/GeoExt/widgets/LegendPanel.html</li>
<li>lib/GeoExt/widgets/LegendWMS.html</li>
<li>lib/GeoExt/widgets/ZoomSlider.html</li>
+ <li>lib/GeoExt/widgets/grid/FeatureSelectionModel.html</li>
</ul>
More information about the Commits
mailing list