<div id="cv-archive-table-header">
    <div class="panel-title">
        <a href="javascript:openDialogNoTitle('<?= url('new',['category_id'=>$category_id]); ?>','650px','520px', true)" class="easyui-linkbutton">+ <?= lang('New'); ?></a>
    </div>
</div>
<table id="cv-archive-table" style="height: 100%;"></table>
<script type="text/javascript">
    $(function () {
        var cvArchiveTable = $('#cv-archive-table');
        var cvArchivePageSize = parseInt((bodyHeight-137)/32);
        cvArchiveTable.datagrid({
            url:'<?= url('index', ['category_id'=>$category_id]); ?>',
            columns:[[
                {field:'ck',checkbox:true,width:10},
                {field:'id',title:'ID',width:15,halign:'center'},
                {field:'title',title:'<?= lang('Title'); ?>',width:250,halign:'center'},
                {field:'status',title:'<?= lang('Status'); ?>',width:25,halign:'center'},
                {field:'author',title:'<?= lang('Author'); ?>',width:25,halign:'center'},
                {field:'actions',title:'<?= lang('Available operations'); ?>',width:70,halign:'center'},
                {field:'create_time',title:'<?= lang('Create time'); ?>',width:70,halign:'center'},
                {field:'update_time',title:'<?= lang('Update time'); ?>',width:70,halign:'center'}
            ]],
            pagination: true,
            scrollbarSize:0,
            pageList: [cvArchivePageSize],
            pageSize: cvArchivePageSize,
            border:false,
            fitColumns: true,
            striped: true,
            header: '#cv-archive-table-header',
            onSelect: function (index,row) {
//                switchInnerCenter('cv-archive-inner-layout','<?//= url('show',['category_id'=>$category_id]); ?>//'+'&archive_id='+row.id);
            },
            onLoadSuccess: function (data) {
//                if (data.total>0){
//                    cvArchiveTable.datagrid('selectRow',0);
//                }else {
//                    switchInnerCenter('cv-archive-inner-layout','<?//= url('show',['category_id'=>$category_id,'archive_id'=>0]); ?>//');
//                }
            }
        });
        var cvArchivePager = cvArchiveTable.datagrid('getPager');
        cvArchivePager.pagination({
            showPageList:false
        });
    });

    function reloadArchiveListData() {
        $('#cv-archive-table').datagrid('reload');
    }
</script>
