2013-05-08 213 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中存储对最后单击的单元格的引用。这也可以通过标准控件完成,您需要从事件目标中提取单击的单元格。