0

HTML を使用して宣言的に作成された Dojo データ グリッドがあります。列を右揃えにする必要があります。次の2つの方法を試しましたが、うまくいきません

1を試す

次の例では、彼align="right"は無視されますが、各要素width="100px"のスタイルに追加されます<td>

<table data-dojo-type="dojox.grid.DataGrid" style="height:100px;">
<thead>
   <tr>
    <th field="col1" width="auto">Col 1</th>
    <th field="col2" width="100px" align="right">Col 2</th>
    <th field="col3" width="100px" align="right">Col 3</th>
   </tr>
</thead>
</table>

トライ2

次の例style="text-align:right;"では、道場によって完全に無視されているようです

<table data-dojo-type="dojox.grid.DataGrid" style="height:100px;">
<thead>
   <tr>
    <th field="col1" width="auto">Col 1</th>
    <th field="col2" width="100px" style="text-align:right;">Col 2</th>
    <th field="col3" width="100px" style="text-align:right;">Col 3</th>
   </tr>
</thead>
</table>
4

1 に答える 1

2

要素でstyles属性を使用する必要があります。<th>名前が示すように、この属性は、<td>その列の s に適用される CSS スタイルを指定します。

マークアップの例:

<body class="claro">
    <table data-dojo-type="dojox.grid.DataGrid" style="width:100%" store="myStore">
        <thead>
            <tr>
                <th field="col1" width="auto" align="left">Col 1</th>
                <th field="col2"  width="100px" align="left">Col 2</th>
                <th field="col3" width="100px" align="right" styles="text-align:right;">Col 3</th>
           </tr>
        </thead>
    </table>
</body>

js の例:

dojo.require('dojox.grid.DataGrid');
dojo.require('dojo.parser');
dojo.require('dojo.data.ItemFileWriteStore');
dojo.ready(function() {
    var data = {
        identifier: 'id',
        items: []
    };
    var data_list = [
        {
        col1: "normal",
        col2: false,
        col3: 29.91},
    {
        col1: "important",
        col2: false,
        col3: 9.33},
    {
        col1: "important",
        col2: false,
        col3: 19.34}
    ];
    var rows = 60;
    for (var i = 0, l = data_list.length; i < rows; i++) {
        data.items.push(dojo.mixin({
            id: i + 1
        }, data_list[i % l]));
    }
    myStore = new dojo.data.ItemFileWriteStore({
        data: data
    });

    dojo.parser.parse();
});​

http://jsfiddle.net/jrkeller/3h6MN/1/

この属性は、こちらの「グリッドの操作」チュートリアルで発見しました

于 2012-07-18T13:45:43.267 に答える