Whether to select all and $filter filter by order in Angularjs

Source: Internet
Author: User



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>
&LT;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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.