Each of my columns will be a complex type.
Using custom formatting I’d like to be able to display the text of one property, then colour the cell (or do anything really) dependant on the other property.
So for example:
public class MyRowObject
{
public MyCellObject Cell1 { get; set; }
public MyCellObject Cell2 { get; set; }
public SomeOtherCellObject Cell3 { get; set; }
}
public class MyCellObject
{
public string MyDisplayText { get; set; }
public int MyNumber { get; set; }
}
then use a custom formatter javascript function to do stuff, for example:
function formatCourseData(cellValue, options, rowObject) {
var linkHTML = cellValue.MyDisplayText;
if (cellValue.MyNumber > 10) {
//format the html in some way
}
return linkHTML;
}
Now I know I cannot do cellValue.MyDisplayText but this or something like is what I would like to be able to do.
Is this possible?
Is it documented anywhere? (I’ve looked, but cannot find anything).
thanks in advance.
What you can do is pass each field of the complex object as its own column, and then within your formatter you can use the formatter’s
rowObjectparameter to access the other value to do anything you need, such as coloring.Alternatively, you may not need to use a second column if each number indicates the same display text. You could just use a select formatter (or a custom version of one), or a lookup table or such.
Anyway, here is an example of how you can use
rowObjectto access row data: access-row-data-in-jqgrid-custom-formatterDoes that help?