0
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>');に追加すると..しかし、追加せずに最初の列の見出しを取得するにはどうすればよいですか。?
ありがとう

4

1 に答える 1

1

試す :

$('th:first').text('Sr.no');

:firstセレクターを使用して最初のth

于 2012-05-15T12:51:06.937 に答える