2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<div class="row">
 
    <div class="col-xs-12">
        <div class="page-header">
            <h1>Loading data - overview</h1>
        </div>
 
        <p>There are broadly two options for getting data loaded into a table. These are discussed below</p>
 
        <dl>
            <dt>1. Managed array</dt>
            <dd>
                Hand <code>NgTableParams</code> an in-memory array and let it do the filtering, sorting and paging
                on that array. Eg:<br/>
<pre style="margin-top:10px" data-prettycode pretty-lang="js">
var data = [{ name: 'christian', age: 21 }, { name: 'anthony', age: 88 }];
var tp = new NgTableParams({}, { data: data });
</pre>
            </dd>
            <dt>2. External array</dt>
            <dd>
                Hand <code>NgTableParams</code> a custom <code>getData</code> function that it will call to load
                data. Eg:<br/>
<pre style="margin-top:10px" data-prettycode pretty-lang="js">
var tp = new NgTableParams({}, { getData: function(params){
    /* code to fetch data that matches the params values */
}});
</pre>
            </dd>
            <dd>Typically you will use this option to load server-side data</dd>
        </dl>
    </div>
</div>