jqgrid format column dynamically
I am trying开发者_开发技巧 to format a jqgrid which has some dynamic columns which I create like this
JQGridColumn column1 = new JQGridColumn() {
DataField = "ID",
PrimaryKey = true
};
ErrorsJQGrid.Columns.Add(column1);
How do I format these columns to have a say 'yellow background color'? I can specify a in the jqgrid columns definition, but since my columns are dynamically generated, I am not sure how it's done from the codebehind.
Here is the link to the demos default formatter, custom formatter
JQGridColumn has the CssClass property which you can use to set custom CssClass for a column. Example:
In HTML
<style type="text/css">
.redColor { background-color: Red; }
</style>
In code
protected void Page_Load(object sender, EventArgs e)
{
JQGridColumn dynamicColumn = new JQGridColumn();
dynamicColumn.DataField = "Freight";
dynamicColumn.CssClass = "redColor";
JQGrid1.Columns.Add(dynamicColumn);
}
Will this work in your scenario?
Cheers, Rumen Stankov Trirand Inc (jqGrid makers)
精彩评论