Skip to content

Instantly share code, notes, and snippets.

@nathan5x-zz
Created April 11, 2018 20:14
Show Gist options
  • Save nathan5x-zz/f22b5bad914b867db31b5f550b0a5b1a to your computer and use it in GitHub Desktop.
Save nathan5x-zz/f22b5bad914b867db31b5f550b0a5b1a to your computer and use it in GitHub Desktop.
Adding sort icon to Dojo Data Grid
function displayDefaultSortIcon(grid, fieldName){
if(grid && grid.layout) {
dojo.forEach(grid.layout.cells, function(cell, idx) {
if(cell.field === fieldName) {
var targetCell = $('#'+cell.id);
if(targetCell) {
targetCell.attr("aria-sort","descending");
var domToAddSortIcon = $(targetCell.find('.dojoxGridSortNode'));
if(domToAddSortIcon) {
domToAddSortIcon.empty();
domToAddSortIcon.toggleClass('dojoxGridSortDown');
domToAddSortIcon.html('<div class="dojoxGridArrowButtonChar">▼</div>\
<div class="dojoxGridArrowButtonNode" role="presentation"></div>\
<div class="dojoxGridColCaption">'+cell.name+'</div>');
}
}
grid.setSortIndex(idx,false);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment