[英]How can i add a table first colum heading. whole table is coming from a table.js library
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>');
它來了..但不添加其他方法,我如何才能獲得第一個欄目標題。 ?
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.