HTML code:
<table class= "Table table-bordered table-list table-striped No-margin-bottom" >
<thead>
<tr>
<th>{{' Column-name ' | translate}}</th>
<th width= ">{{' Primary-key ' | translate}}</th>
<th width= ">{{' Required ' | translate}}</th>
<th width= ">"
<md-checkbox class= "No-margin-bottom" aria-label= "checked" ng-checked= "table. Allcolumnchecked "//Set all Select button Initial state (bidirectional binding) Ng-click= "$ctrl.Checkedallcolumn(table) "></md-checkbox>
{' Select-all ' | translate}}
</th>
</tr>
</thead>
<tbody>
<TR ng-repeat= "column intable. Table.listcolumn | By: ' Displayorder ' ">
<td>{{column | columntranslatefilter}}</td>
<td><span ng-if= "column. IsPrimaryKey ">{{' true ' | translate}}</span></td>
<td><span ng-if= "column. IsRequired ">{{' true ' | translate}}</span></td>
<td>
<md-checkbox class= "No-margin-bottom" aria-label= "checked"
Ng-checked= "Column.checked"
Ng-disabled= "column. IsPrimaryKey "
Ng-click= "$ctrl. Checkedcolumn (table,column)" ></md-checkbox>
</td>
</tr>
</tbody>
</table>
js code:
self.checkedAllColumn = function (table) {
table.AllColumnChecked =! table.AllColumnChecked;
if (table.AllColumnChecked) {
table.Table.ListColumn.forEach (function (col) {
col.checked = true;
})
table.ListColumn = $ filter (‘orderBy’) (table.Table.ListColumn, ‘DisplayOrder’ // sort conditions);
} else {
table.Table.ListColumn.forEach (function (col) {
col.checked = false;
})
table.ListColumn = [];
}
};
Select All: When you click the Select All button (checkedAllColumn), the condition in the if statement becomes true, then all column options (table.Table.ListColumn) are filtered and the status is changed to selected (col.checked = true;);
When deselecting all, the condition in the if statement becomes false, then jump to else to filter all column options and uncheck the state;
orderBy sorting: $ filter (‘oederBy’) in js gets all the column options and sorts them according to the sorting conditions; in HTML, use | orderBy: ‘ordering conditions’ to get the sorting list;
Whether to select all and $filter filter by order in Angularjs