如何在css中的同步网格分组控制中的特定单元格上添加CSS

时间:2017-12-18 09:48:09

标签: css events grid syncfusion

我想在特定列上添加自定义cssClass。但我的下面的代码在GridRowData Bound事件中工作,但在GridHeaderRowDataBound事件中不起作用。我怎么能在GridHeaderRowDataBound事件中添加一个CSS类呢?

GridRowDataBound事件:

public void Entity_GridRowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e, AHS.Security.Screen screen, int objectID)
    {
        switch (screen.ID)
        {
            case 3489://Expiring Agreements
                e.Row.Cells[0].CssClass = "hideColumn";
                break;

        }
    }

GridHeaderRowDataBound事件:

     public void Entity_GridHeaderRowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e, AHS.Security.Screen screen, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableDescriptor tdescriptor)  
        {
        switch (screen.ID)
        {
            case 3489:
                e.Row.Cells[0].CssClass = "hideColumn";

                tdescriptor.Columns[9].HeaderText = "  ";
                tdescriptor.Columns[9].Name = "  ";
                tdescriptor.Columns[9].MappingName = "  ";
                break;

        }
      }

1 个答案:

答案 0 :(得分:0)

我们没有名为headerRowDataBound的事件。您可以使用下面的代码更改标题css

this.GridGroupingControl1.TableDescriptor.Columns[0].Appearance.ColumnHeaderCell.CssClass = "MyClass";
this.GridGroupingControl1.TableDescriptor.Columns[0].HeaderText = "MyHeader";
this.GridGroupingControl1.TableDescriptor.Columns[0].MappingName = "Header";