|
The easiest way to active Excel export is setting $this->nav['excel'] = true
The first Excel button is generated this way.
Please note: export preserves current sorting and filtering.
Of course, you may create your own export button with custom handler.
The second button is created that way.
Простейший способ включить экспорт в Excel - установить $this->nav['excel'] = true
При этом экспортируются сразу все страницы, сохраняя текущий поиск и сортировку.
Первая кнопка создана именно таким образом.
Вы также можете задать свои параметры экспорта. При клике на вторую кнопку пользователя спросит, сколько рядов
экспортировать.
higrid.net嗨网提供电子表格、在线图形等互联网开发及运营技术,提供相关资料及软件下载,分享奇趣网络时事评论!欢迎访问。
部分内容为俄文,higrid计划翻译一下。敬请期待!
php代码和js代码请点击tab查看。
<?php
class jqOutExcel extends jqGrid
{
protected function init()
{
#This is all you need for simple Excel export
$this->nav = array('excel' => true);
$this->table = 'tbl_customer';
$this->cols = array(
'id' => array('label' => 'ID',
'width' => 10,
'align' => 'center',
),
'first_name' => array('label' => 'First name',
'width' => 35,
),
'last_name' => array('label' => 'Last name',
'width' => 35,
),
'email' => array('label' => 'Email',
'width' => 30,
),
'phone' => array('label' => 'Phone',
'width' => 25,
'align' => 'center',
),
'discount' => array('label' => 'Discount',
'width' => 15,
'formatter' => 'numeric',
'align' => 'center',
),
);
}
}
<script>
<?= $rendered_grid ?>
$grid.filterToolbar();
//custom excel export
$grid.jqGrid("navButtonAdd", pager,
{
caption:"Excel some rows",
title:"Excel",
icon:"ui-extlink",
onClickButton:function () {
var rows = prompt("How many rows to export?");
if (!rows) return;
$(this).jqGrid("extExport", {"export":"ExcelHtml", "rows":rows});
}
});
</script>
|