| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Custom Sort Test - dojox.grid.Grid</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <style type="text/css"> |
| 8 | @import "../resources/Grid.css"; |
| 9 | body { |
| 10 | font-size: 0.9em; |
| 11 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 12 | } |
| 13 | .heading { |
| 14 | font-weight: bold; |
| 15 | padding-bottom: 0.25em; |
| 16 | } |
| 17 | |
| 18 | #grid { |
| 19 | border: 1px solid #333; |
| 20 | width: 35em; |
| 21 | height: 30em; |
| 22 | } |
| 23 | </style> |
| 24 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 25 | data-dojo-config="isDebug:false, parseOnLoad: true"></script> |
| 26 | <script type="text/javascript"> |
| 27 | dojo.require("dijit.dijit"); |
| 28 | dojo.require("dojox.grid.DataGrid"); |
| 29 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 30 | dojo.require("dojo.parser"); |
| 31 | </script> |
| 32 | <script type="text/javascript" src="support/test_data.js"></script> |
| 33 | <script type="text/javascript"> |
| 34 | test_store.comparatorMap = {}; |
| 35 | test_store.comparatorMap["col1"] = function(a, b){ |
| 36 | var ret = 0; |
| 37 | // We want to map these by what the priority of these items are, not by alphabetical. |
| 38 | // So, custom comparator. |
| 39 | var enumMap = { "important": 0, "normal": 1, "note": 2 }; |
| 40 | if (enumMap[a] > enumMap[b]) { |
| 41 | ret = 1; |
| 42 | } |
| 43 | if (enumMap[a] < enumMap[b]) { |
| 44 | ret = -1; |
| 45 | } |
| 46 | return ret; |
| 47 | } |
| 48 | var layout = [[ |
| 49 | {name: 'Column 1', field: 'col1'}, |
| 50 | {name: 'Column 2', field: 'col2'}, |
| 51 | {name: 'Column 3', field: 'col3'}, |
| 52 | {name: 'Column 4', field: 'col4', width: "150px"}, |
| 53 | {name: 'Column 5', field: 'col5'} |
| 54 | ],[ |
| 55 | {name: 'Column 6', field: 'col6'}, |
| 56 | {name: 'Column 7', field: 'col7'}, |
| 57 | {name: 'Column 8'}, |
| 58 | {name: 'Column 9', field: 'col3', colSpan: 2} |
| 59 | ]]; |
| 60 | </script> |
| 61 | </head> |
| 62 | <body> |
| 63 | <div class="heading">dojox.grid.Grid Custom Sort Test</div> |
| 64 | <br /> |
| 65 | <b>Column 1</b>'s data field has a custom sorter that sorts by the status level rather than alphebetically |
| 66 | <br /><br /> |
| 67 | <div id="grid" data-dojo-id="grid" dojoType="dojox.grid.DataGrid" store="test_store" structure="layout"></div> |
| 68 | </body> |
| 69 | </html> |