Changeset 61463 in webkit
- Timestamp:
- Jun 18, 2010 8:23:38 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61462 r61463 1 2010-06-18 Jessie Berlin <jberlin@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Bug 19509 - Database Tables in the Inspector should be sortable 6 https://bugs.webkit.org/show_bug.cgi?id=19509 7 8 * inspector/front-end/StoragePanel.js: 9 (WebInspector.StoragePanel.prototype.dataGridForResult): 10 Make each column in the DataGrid sortable. 11 (WebInspector.StoragePanel.prototype._sortDataGrid.comparator): 12 Make sure to sort numeric columns by their numeric values, instead of lexicographically. 13 (WebInspector.StoragePanel.prototype._sortDataGrid): 14 Sort the entries in the DataGrid based on the selected column. 15 1 16 2010-06-18 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/WebCore/inspector/front-end/StoragePanel.js
r54436 r61463 290 290 column.width = columnIdentifier.length; 291 291 column.title = columnIdentifier; 292 column.sortable = true; 292 293 293 294 columns[columnIdentifier] = column; … … 314 315 dataGrid.appendChild(nodes[i]); 315 316 317 dataGrid.addEventListener("sorting changed", this._sortDataGrid.bind(this, dataGrid), this); 316 318 return dataGrid; 319 }, 320 321 _sortDataGrid: function(dataGrid) 322 { 323 var nodes = dataGrid.children.slice(); 324 var sortColumnIdentifier = dataGrid.sortColumnIdentifier; 325 var sortDirection = dataGrid.sortOrder === "ascending" ? 1 : -1; 326 var columnIsNumeric = true; 327 328 for (var i = 0; i < nodes.length; i++) { 329 if (isNaN(Number(nodes[i].data[sortColumnIdentifier]))) 330 columnIsNumeric = false; 331 } 332 333 function comparator(dataGridNode1, dataGridNode2) 334 { 335 var item1 = dataGridNode1.data[sortColumnIdentifier]; 336 var item2 = dataGridNode2.data[sortColumnIdentifier]; 337 338 var comparison; 339 if (columnIsNumeric) { 340 // Sort numbers based on comparing their values rather than a lexicographical comparison. 341 var number1 = parseFloat(item1); 342 var number2 = parseFloat(item2); 343 comparison = number1 < number2 ? -1 : (number1 > number2 ? 1 : 0); 344 } else 345 comparison = item1 < item2 ? -1 : (item1 > item2 ? 1 : 0); 346 347 return sortDirection * comparison; 348 } 349 350 nodes.sort(comparator); 351 dataGrid.removeChildren(); 352 for (var i = 0; i < nodes.length; i++) 353 dataGrid.appendChild(nodes[i]); 317 354 }, 318 355
Note: See TracChangeset
for help on using the changeset viewer.