2013-05-08 146 views
-1

我有一個基於兩個網格值自動生成的表格。 我希望能夠選擇每個單獨的單元格(不是多個單元格),並且在單元格選擇上應該出現一個RadWindow。所選單元格的外框應變爲粗體。在RadWindow中是一個RadColor選取器,拾取的顏色將改變單元格的背景。 我看了一堆在線類似事件的例子,但由於我缺少jQuery和JS知識,我不確定如何去做這件事。選擇表格單元格

我的表看起來像這樣:

<asp:Table ID="Table1" runat="server" BorderStyle="Solid" BorderWidth="7px" 
    CellPadding="40" CellSpacing="15" Font-Bold="True" Font-Size="XX-Large" 
    GridLines="Both" HorizontalAlign = "Center"> 
</asp:Table> 

爲表生成的隱藏代碼:

public void Generate_Matrix() 
{ 
    // Total number of rows. 

    int rowCnt = CCT.Rows.Count; 

    // Current row count. 
    int rowCtr; 
    // Current cell counter 
    int cellCtr = 0; 
    // Total number of cells per row (columns). 
    int cellCnt = LCT.Rows.Count; 
    for (rowCtr = 1; rowCtr <= rowCnt; rowCtr++) 
    { 
     // Create new row and add it to the table. 
     TableRow tRow = new TableRow(); 
     for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++) 
     { 
      // Create a new cell and add it to the row. 
      TableCell tCell = new TableCell(); 
      tCell.Text = rowCtr + "" + cellCtr; 
      tRow.Cells.Add(tCell); 
     } 
     Table1.Rows.Add(tRow); 
    } 

} 
+0

雖然實際的問題是什麼?什麼不起作用? – 2013-05-08 17:57:12

+0

我不確定如何執行此操作。其實,我所需要知道的是如何創建一個選擇單元格功能,其餘的我可以自己弄清楚。 – puntubabu 2013-05-08 18:00:03

回答

0

瞭解如何與radgrid控件細胞在這裏工作:http://demos.telerik.com/aspnet-ajax/grid/examples/client/cellselection/defaultcs.aspx 瞭解如何調用函數在RadWindow裏面的主頁面上:http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx,所以你可以傳遞新的顏色。或者使用RadWindow的ContentTemplate,這樣你就可以在相同的上下文中使用顏色選擇器:http://www.telerik.com/help/aspnet-ajax/window-programming-calling-functions.html。 例如,在全局JS var中存儲對最後單擊的單元格的引用。這也可以通過標準控件完成,您需要從事件目標中提取單擊的單元格。

相關問題