jQuery EasyUI Data Grid -Пользовательская пагинация

DataGrid имеет встроенную функцию постраничной навигации, которая очень полезна, а ее настройка довольно проста. В этом руководстве мы создадим DataGrid и добавим несколько пользовательских кнопок на панель постраничной навигации.

Создание DataGrid

    <table id="tt" title="Load Data" class="easyui-datagrid" style="width:550px;height:250px"
            url="data/datagrid_data.json"
            iconCls="icon-save" pagination="true">
        <thead>
            <tr>
                <th field="itemid" width="80">Item ID</th>
                <th field="productid" width="80">Product ID</th>
                <th field="listprice" width="80" align="right">List Price</th>
                <th field="unitcost" width="80" align="right">Unit Cost</th>
                <th field="attr1" width="100">Attribute</th>
                <th field="status" width="60" align="center">Stauts</th>
            </tr>
        </thead>
    </table>

Не забудьте установить свойство 'pagination' в true, чтобы была создана панель постраничной навигации.

Настройка панели инструментов постраничной навигации

    var pager = $('#tt').datagrid('getPager');    // get the pager of datagrid
    pager.pagination({
        showPageList:false,
        buttons:[{
            iconCls:'icon-search',
            handler:function(){
                alert('search');
            }
        },{
            iconCls:'icon-add',
            handler:function(){
                alert('add');
            }
        },{
            iconCls:'icon-edit',
            handler:function(){
                alert('edit');
            }
        }],
        onBeforeRefresh:function(){
            alert('before refresh');
            return true;
        }
    });

Как видите, сначала мы получаем объект pager компонента DataGrid, а затем заново создаем пагинацию. Мы скрываем список страниц и добавляем три новые кнопки.

Скачать примеры jQuery EasyUI

jeasyui-datagrid-datagrid11.zip

Другие расширения