Skip to content

Instantly share code, notes, and snippets.

@Restoration
Last active June 23, 2023 07:42
Show Gist options
  • Save Restoration/f96c6e55f18a8297483c6a7e98144a7c to your computer and use it in GitHub Desktop.
Save Restoration/f96c6e55f18a8297483c6a7e98144a7c to your computer and use it in GitHub Desktop.
sortComparator: (v1, v2, param1, param2) => {
if (v1 !== v2) {
// isCheckedの値が異なる場合、そのまま比較結果を返す
return v1 ? -1 : 1;
}
// isCheckedが同じ場合、isSelectedを比較する
const isSelected1 = param1.api.getRow(param1.id).isSelected;
const isSelected2 = param2.api.getRow(param2.id).isSelected;
if (isSelected1 !== isSelected2) {
// isSelectedの値が異なる場合、そのまま比較結果を返す
return isSelected1 ? -1 : 1;
}
// isSelectedも同じ場合、nameを比較する
const name1 = param1.api.getRow(param1.id).name;
const name2 = param2.api.getRow(param2.id).name;
return name1.localeCompare(name2, 'ja');
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment