JSON Data in Template Column

Dear,
as per your example onhttps://www.syncfusion.com/kb/2465/how-to-display-array-of-strings-within-a-grid-columnI have a dataGrid, bound to a JSON object.
Some of the return values in the JSON are Generic .NET Lists. For example :
Public ReadOnly Property ExtraQuantities As List(Of InventoryExtraQuantity)
Public Class InventoryExtraQuantity
Public Property UnitId As Integer
Public Property UnitDescription As String
Public Property MeasurementUnitId As Integer
Public Property MeasurementUnitDescription As String
Public Property Quantity As Double
Public Property Id As Integer
End Class
JSON
[
{
"StockId":8903,
"StockInfoConfigId":4849,
"OperationalDate":"2020-01-28T00:00:00",
"InternalCompanyId":2,
"InternalCompanyName":"Gheeraert",
"ProductId":67,
"ProductName":"R42301",
"ProductCode":"R42301",
"OwnerId":22,
"OwnerName":"Taghleef",
"LocationId":8122,
"LocationName":"ZE01B1C01",
"BaseUnitId":22,
"BaseUnitDesc":"Piece",
"BaseUnitQuantity":1.0,
"Status":"Available",
"StorageUnitId":21,
"StorageUnitDesc":"Pallet",
"StorageUnitQuantity":1.0,
"BaseMeasurementUnitId":null,
"BaseMeasurementUnitDesc":null,
"TrackingNumber":"DV-002316",
"InventoryNumber":"0100201135",
"DateIn":"2020-01-28T00:00:00",
"ExpiryDate":null,
"ProductionDate":null,
"Lot":"DV-002316",
"ItemNumber":"141061785",
"PackagingUnit":null,
"PickingList":null,
"Sids":[
{
"SidId":7,
"Description":"BalanceOrderNumber",
"Value":"2019/O/12702/1",
"DisplayValue":"2019/O/12702/1",
"Id":0
}
],
"ExtraQuantities":[
{
"UnitId":2,
"UnitDescription":"Net",
"MeasurementUnitId":1,
"MeasurementUnitDescription":"kg",
"Quantity":295.0,
"Id":0
},
{
"UnitId":3,
"UnitDescription":"Gross",
"MeasurementUnitId":1,
"MeasurementUnitDescription":"kg",
"Quantity":257.0,
"Id":0
},
{
"UnitId":24,
"UnitDescription":"Oppervlakte",
"MeasurementUnitId":9,
"MeasurementUnitDescription":"m2",
"Quantity":7400.0,
"Id":0
}
],
"Id":0
},
I would like to Add a Template Column for the ExtraQuantity with UnitDescription "Net" and a Template Column for the ExtraQuantity with UnitDescription "Gross". I have this as code:
DataGrid:


I get an error value in the Template Column: Cannot read property 'filter' of null. What is wrong?
Source code and JSON file attached.
Peter

Attachment: Inventory_e7298367.zip

1 Reply

PK Padmavathy Kamalanathan Syncfusion Team February 27, 2020 12:12 PM UTC

Hi Peter,

Thanks for contacting Syncfusion Forums.

QUERY: error in Template Column: 'Cannot read property 'filter' of null. What is wrong?

From your query we understand that you are trying to display array of strings within a grid column using the helper function. But you are getting error "cannot read property filter of null". 

Below is the screenshot of your code:

Screenshot1:



We have validated the reported issue at our end. We are unable to reproduce the reported issue at our end. The reported issue occurs only when the "val" is a  null value. So we suggest you to check if you get any "val" as a null value in "_getVal" method. 

If you get the "val" properly in the "_getVal" method properly as we have shown in the below screenshot, you can render the column template properly

Screenshot2:



You are trying to filter the "ExtraQuantities" by checking whether the UnitDescription value is equal to "Net". If it is equal, then the "Quantity" value will be filtered and set to the column template. But you have used [return p.UnitDescription = property]  instead of p.UnitDescription ==  property]. That is you have just assigned the property to the UnitDescription value instead of checking using "==".

We have also prepared sample as per your requirement for your reference. You can download that from the below location,

If you have further queries, please get back to us.

Regards,
Padmavathy Kamalanathan


Loader.
Up arrow icon