WebDataGrid是一款功能强大的表格控件,包含在infragistics ASP.NET里,该控件无论客户端还是服务器端都可以对表格数据和样式进行操作,这里主要介绍如何在客户端设置所有单元格颜色,具体代码如下:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" >
<ClientEvents Initialize="WebDataGrid1_Grid_Initialize" />
</ig:WebDataGrid>
function WebDataGrid1_Grid_Initialize(sender, eventArgs)
{
///<summary>
///
///</summary>
///<param name="sender" type="Infragistics.Web.UI.ControlMain"></param>
///<param name="eventArgs" type="Infragistics.Web.UI.EventArgs"></param>
var grid = $IG.WebDataGrid.find('<%= WebDataGrid1.ClientID %>');
var rows = grid.get_rows();
for (var i = 0; i < rows.get_length(); i++) {
var row = rows.get_row(i);
for (var j = 0; j < row.get_cellCount(); j++) {
var cell = row.get_cell(j);
var element = cell.get_element();
element.style.backgroundColor = 'Red';
}
}
}