Skip to content

Commit 05a56ea

Browse files
committed
Merge pull request #16 from dolin5/attribute-table-tab-closure-and-sort
Attribute table tab closure and sort
2 parents 108515c + 804cc95 commit 05a56ea

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

widgets/AttributesTable.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,13 @@ define([
135135
if (!options.id) {
136136
options.id = 'attrTab-' + options.topicID;
137137
}
138+
if (typeof options.closable == 'undefined'){
139+
options.closable = true;
140+
}
141+
if (typeof options.confirmClose == 'undefined'){
142+
options.confirmClose = true;
143+
}
138144
options.map = this.map;
139-
options.closable = true;
140145
options.sidebarID = this.sidebarID;
141146

142147
if (this.useTabs) {
@@ -154,7 +159,7 @@ define([
154159
tab.startup();
155160
tabs.addChild(tab);
156161
tab.onClose = lang.hitch(tab, function () {
157-
var close = confirm('Do you really want to close this tab?');
162+
var close = this.confirmClose ? confirm('Do you really want to close this tab?') : true;
158163
if (close && this.clearAll) {
159164
this.clearAll();
160165
}

widgets/AttributesTable/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ define({
9393
// other instances of attributes table
9494
topicID: 'query',
9595

96+
// allow tabs to be closed
97+
// confirm tab closure
98+
closable: true,
99+
confirmClose: true,
100+
96101
queryOptions: {
97102
// parameters for the query
98103
queryParameters: {
@@ -225,7 +230,7 @@ gridOptions: {
225230
columns: [],
226231

227232
/*
228-
no sort
233+
no sort, use sort: 'inherit' to use the order of the query results.
229234
*/
230235
sort: [],
231236

widgets/AttributesTable/_GridMixin.js

+4
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ define([
251251

252252
// set the sort
253253
var sort = this.gridOptions.sort || [];
254+
// sort === 'inherit'? use query result order
255+
if (typeof sort === 'string' && sort.toLowerCase() === 'inherit'){
256+
return;
257+
}
254258
// no sort? use the first column
255259
if (sort.length < 1 && columns && columns.length > 0) {
256260
sort = [

0 commit comments

Comments
 (0)