2012-07-18 3 views
0

html을 사용하여 선언적으로 작성된 Dojo 데이터 격자가 있습니다. 기둥을 오른쪽 정렬해야합니다. 나는 그것이Dojo Datagrid의 컬럼을 선언적으로 오른쪽 정렬하는 방법

다음 예에서 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

시도 0은 완전 도장

당신은 <th> 요소에 styles 속성을 사용할 필요가
<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> 
+0

당신이 무엇을 원하는 않습니다 "그리드 작업"튜토리얼이 속성을 발견 오른쪽 정렬? 열 자체? 또는 열 내의 텍스트? 나는 dojo docs (http://jsfiddle.net/jrkeller/3h6MN/)에서 그리드 어 피어 런스를 보여주기 위해 빠른 바이올린을 집어 넣었지만 당신이 무엇을 요구하는지 이해하지 못한다. – BuffaloBuffalo

+0

@BuffaloBuffalo - 열 내의 텍스트를 오른쪽 정렬하고 싶습니다. Col2 및 Col3에는 소수 2 자리 숫자가 있습니다. 십진수가 일렬로 정렬되기를 바랍니다. – Danish

+0

@BuffaloBuffalo - jsfiddle을 가져 주셔서 감사합니다. 텍스트를 오른쪽 정렬 할 수 없습니다. – Danish

답변

2

에 의해 무시 될 것으로 보인다. 이름에서 알 수 있듯이이 속성은 해당 열에 대해 <td>에 적용될 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/

나는 here

+0

감사합니다. 당황 스럽지만, 자습서를 통해 프로그래밍 방식으로 생성 한 모든 그리드를 작성하고 단순히 선언적 형식으로 시도해 보는 것이 좋습니다. – Danish

+0

'styles' 속성이 html 요소를 넣기에 믿을 수 없을 정도로 비현실적이라는 데는 도움이되지 않습니다. – BuffaloBuffalo

관련 문제