BA.Table.prototype.drawHeader = function()
{
if ( ! this.headHTML ) {
this.headHTML = $('<thead/>');
var tr = $('<tr/>');
var didSort = false;
if ( ! this.config.noIndex ) {
var th = $('<th class="table_index"></th>');
th.appendTo(tr);
}
for( var ix = 0; ix < this.children.length; ix++ ) {
var child = this.children[ix];
if ( child instanceof BA.InputHidden
|| ( child.config && child.config.hidden ) )
{
continue;
}
if ( ! child.config.id ) {
child.config.id = 'c' + ix;
}
var label = child.config.label ? child.config.label : '';
var labelHTML;
if ( child.config.title ) {
labelHTML = $('<th><span title="' + child.config.title + '">' + label + '</span></th>');
} else if ( child.config.sort ) {
var a = $('<a href="#" id="sort_' + child.config.id + '">' + label + '</a>');
a.bind('click', {t: this, i: ix}, function(event) { event.data.t.sortByColumn(event.data.i); return false; });
if ( child.config.sorted ) {
var img = child.config.sorted > 0 ? 'up' : 'down';
$('<img src="' + window.IMAGES_PATH + img + '.gif"/>').appendTo(a);
}
labelHTML = $('<th/>');
a.appendTo(labelHTML);
} else {
labelHTML = $('<th>' + label + '</th>');
}
labelHTML.appendTo(tr);
child.hideLabel = true;
}
if ( this.config.canAddRows === undefined || this.config.canAddRows == true
|| this.config.canDeleteRows
) {
var labelHTML = $('<th class="action"> </th>');
$(labelHTML).appendTo(tr);
}
tr.appendTo(this.headHTML);
this.headHTML.appendTo(this.tableHTML);
}
}; <br>
以上是创建表的常用库。使用json对象绘制表格下面是php页面
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<script type="text/javascript">
var listLayout = {
o: 'Page',
c: [
{ o: 'Form', id: 'list', name: 'list', c: [
{ o: 'Table', canAddRows: false, value: [],
caption: { c: [
{ o: 'Button', label: '<?php echo lang("add_new_volume");?>', id: 'vr_add_icon' }
]},
c: [
{ o: 'HTML', label: '<?php echo lang('volumes');?>', id: 'volumes_', 'class': 'name' },
{ o: 'HTML', label: '<?php echo lang('type');?>', id: 'type_', 'class': 'type' },
{ o: 'HTML', label: '<?php echo lang('drives');?>', id: 'drives_', 'class': 'driver' },
{ o: 'HTML', label: '<?php echo lang('usage');?>', id: 'usage_', 'class': 'usage' },
{ o: 'HTML', label: '<?php echo lang('size');?>', id: 'size_', 'class': 'size' },
{ o: 'HTML', label: '<?php echo lang('status');?>', id: 'status_', 'class': 'status' },
{ o: 'HTML', label: '<?php echo lang('operations');?>', id: 'action_' }
]},
{
o: 'HTML',
html: '<div class="mv_ajax_status"></div>'
}
]}
]
在上图中,缺少第一个列标题.. 如果没有编辑库,我如何为第一列添加 Sr.no。我需要第一个列标题名称是 Sr.no。但没有向主库添加任何内容..
if ( ! this.config.noIndex ) {
var th = $('<th class="table_index"></th>');
th.appendTo(tr);
}
如果我在 var th = $('<th class="table_index">Sr.no</th>');
它上面添加了..但是不添加它们我怎么能得到第一个列标题。?
谢谢