2012-11-23 42 views
4

我有一個二維數組二維數組ext.net網格視圖

 for (int i = 0; i < rowList.GetLength(0); i++) 
     { 
      for (int j = 0; j < rowList.GetLength(1); ++j) 
      { 
       System.Diagnostics.Debug.WriteLine(rowList.GetValue(i,j)); 

      } 
     } 

我怎樣才能顯示在ext.netgridPanel

這個信息,我有一些代碼在這樣aspx頁面:

 <ext:GridPanel ID="GridPanel1" runat="server" Title="SLA-Einhaltung gesamt in % (Basis) " Height="200" Width="800" Frame="true"> 
     <Store> 
      <ext:Store runat="server" ID="Store1"> 
       <Model> 
        <ext:Model runat="server" IDProperty="ModelID"> 
         <Fields> 
          <ext:ModelField Name="SLA_typ"></ext:ModelField> 
         </Fields> 
        </ext:Model> 
       </Model> 
      </ext:Store> 
     </Store> 

     <ColumnModel runat="server"> 
      <Columns> 
       <ext:Column runat="server" DataIndex="SLA_typ" Width="120" Text="Tittle"></ext:Column> 
      </Columns> 
     </ColumnModel> 
     </ext:GridPanel> 

回答

2

我不知道ext.net gridPanel。但我查了一下,發現樣本http://examples.ext.net/#/GridPanel/ArrayGrid/Simple/該樣本使用鋸齒狀數組,而不是二維數組。鋸齒狀數組是一組數組。

我有與WPF網格相同的問題,解決方案是創建一個鋸齒狀的數組。所以我會嘗試一個鋸齒狀的數組。這就是您如何從rowList陣列創建鋸齒陣列的方法。

object [][] jagged = new object[rowList.GetLength(0)][]; 

    for (int i = 0; i < rowList.GetLength(0); i++) 
    { 
     jagged[i] = new object[GetLength(1)]; 

     for (int j = 0; j < rowList.GetLength(1); ++j) 
     { 
      jagged[i][j] = rowList[i,j]; 

     } 
    }