I have used igGrid with RowTemplate defined. Now when I used the Format function it give me exception " Object doesn't support property or method 'replace'"
RowTemplate = "<tr><td>${Data.ID}</td><tr>
this is the statement I used to format the column
column.For(obj => obj.Data.ID).HeaderText("User ID").DataType("number").Format("number");
Regards,
Ali Qureshi
Hi there Ali,
If Data is the data source that you're providing to the grid, then I assume that your template should look like this:
rowTemplate: "<tr><td>${ID}</td><tr>"
Thank you for using the Infragistics forums!
Data is not the data source in this case, actually data source is complex type where I have "Data" as property in data source which actually contains the property "ID".
Hi again,
The issue then is with the formatter as you originally suggested. The templating engine can process such objects but the built-in formatter cannot, I think. You can include your version of this formatter as a custom formatter and resolve the object value, then you won't be getting an exception.
Let me know if this is helpful to you in any way!
Hi,
Thanks for the quick response. Can you please guide me how to include custom formatter? Is there any sample available to implement custom formatter?
Hello Ali,
I assume that you need to show the data from a complex object in igGrid. In this case you should create a bound column for one of the properties of the complex object which you want to display in the grid and use a formatter function to display its value. This is needed in order for the complex object to be serialized correctly to the browser.
Any additional properties which you want to show in the grid should be declared as an unbound columns. You can populate the unbound columns with a formula function.
Here is an example code:
// One of the properties of a complex object should be declared as a bound column
column.For(obj => obj.Data).HeaderText("User ID").DataType("object").FormatterFunction("function(val) {return val.ID;}");
// Any additional properties should be declared as an unbound column
column.Unbound("UnboundUserName").HeaderText("User Name").Formula("getUserName");
<script type="text/javascript">
function getUserName(row) {
return row.Data.UserName;
}
</script>
Do not hesitate to ask if you have further questions.
Best regards,Martin Pavlov
Infragistics, Inc.