How to use json subitems in Material Table with sorting

Active3 hr before
Viewed126 times

4 Answers


Unity does not support passing other types directly to the API, such as primitive types or arrays, If you need to convert those, wrap them in a class or struct of some sort

Example_snippet/controller/utility/_sorting.js/ [Serializable] public class My. . .
public class MyClass {
   public int level;
   public float timeElapsed;
   public string playerName;
load more v

Nested object data (arrays) , Javascript sourced data ,The example below shows DataTables reading information for the columns from nested objects and arrays, where the structure of the row's data source in this example is:,This table loads data by Ajax, The latest data that has been loaded is shown below

Example_snippet/controller/utility/_sorting.js/ { "name": "Tiger Nixon", "hr. . .
   "name": "Tiger Nixon",
   "hr": {
      "position": "System Architect",
      "salary": "$3,120",
      "start_date": "2011/04/25"
   "contact": [

Example_snippet/controller/utility/_sorting.js/ const initialSelection = []; c. . .
const initialSelection = [];
const allowMultiSelect = true;
this.selection = new SelectionModel<MyDataType>(allowMultiSelect, initialSelection);

Sort does NOT work by itself, In typescript define,So you get a reference to MatSort and just sort the items yourself by subscribing to the changes + rendering rows of the table

Example_snippet/controller/utility/_sorting.js/ @ViewChild(MatSort) sort: MatS. . .
@ViewChild(MatSort) sort: MatSort;
@ViewChild(MatTable) table: MatTable<any>;
private unsubscribe: Subject<void> = new Subject();

ngAfterViewInit() {
      subscribe(() => this.sortTable());

private sortTable() {
// Use (column name, e.g. 'width', this.sort.direction (string 'asc' or 'desc') 
// to sort the array of your items and call

ngOnDestroy() {;