Angularjs ng-table plug-in Settings ordering _angularjs

Source: Internet
Author: User


Basic concepts



Ng-table provides a table header to provide basic filtering information:



(1) Specify a column of filters, and then the template will be used.
(2) ngtable supports number, text, select, and select-multiple value templates.
(3) may have the choice to provide the initial filter value for the Ngtableparams.


<div class = "row">
 <div class = "col-md-6" ng-controller = "demoController as demo">
  <h3> ngTable directive </ h3>
  <table ng-table = "demo.tableParams" class = "table table-condensed table-bordered table-striped">
  <tr ng-repeat = "row in $ data">
   <td data-title = "'Name'" filter = "{name: 'text'}"> {{row.name}} </ td>
   <td data-title = "'Age'" filter = "{age: 'number'}"> {{row.age}} </ td>
   <td data-title = "'Money'"> {{row.money}} </ td>
   <td data-title = "'Country'" filter = "{country: 'select'}" filter-data = "demo.countries"> {{row.country}} </ td>
  </ tr>
  </ table>
 </ div>
 <div class = "col-md-6" ng-controller = "dynamicDemoController as demo">
  <h3> ngTableDynamic directive </ h3>
  <table ng-table-dynamic = "demo.tableParams with demo.cols" class = "table table-condensed table-bordered table-striped">
  <tr ng-repeat = "row in $ data">
   <td ng-repeat = "col in $ columns"> {{row [col.field]}} </ td>
  </ tr>
  </ table>
 </ div>
 </ div>
(function () {
 "use strict";
 var app = angular.module ("myApp", ["ngTable", "ngTableDemos"]);
 app.controller ("demoController", demoController);
 demoController. $ inject = ["NgTableParams", "ngTableSimpleMediumList", "ngTableDemoCountries"];
 // Inject NgTableParams (ngtablemodule) and ngTableSimpleMediumList, ngTableDemoCountries two data sources
 function demoController (NgTableParams, simpleList, countries) {
 this.countries = countries; // Initialize the data source of selcet
 this.tableParams = new NgTableParams ({
  // initial filter
  filter: {name: "T"} // Initial filter condition
 }, {
  dataset: simpleList
 });
 }


 app.controller ("dynamicDemoController", dynamicDemoController);

 dynamicDemoController. $ inject = ["NgTableParams", "ngTableSimpleMediumList", "ngTableDemoCountries"];

 function dynamicDemoController (NgTableParams, simpleList, countries) {
 this.cols = [// Custom table entry, filter condition, table header name and data source, filterData: countries.
  {field: "name", title: "Name", filter: {name: "text"}, show: true},
  {field: "age", title: "Age", filter: {age: "number"}, show: true},
  {field: "money", title: "Money", show: true},
  {field: "country", title: "Country", filter: {country: "select"}, filterData: countries, show: true}
 ];

 this.tableParams = new NgTableParams ({
  // initial filter
  filter: {country: "Ecuador"} // Initialize the data source
 }, {
  dataset: simpleList
 });
 }
}) ();


(function () {
 "use strict";

 angular.module ("myApp"). run (setRunPhaseDefaults);
 setRunPhaseDefaults. $ inject = ["ngTableDefaults"];
// Set the number of tables through config
 function setRunPhaseDefaults (ngTableDefaults) {
 ngTableDefaults.params.count = 5;
 ngTableDefaults.settings.counts = [];
 }
}) (); 



The above is the Angularjs ng-table plug-in data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!


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.