# Rendering a view to a table : Unable to bind the view\_params

**URL:** <https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895>\
**Category:** Ignition\
**Created:** [November 14, 2023, 8:47pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895 "2023-11-14T20:47:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bharat\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Bharat\_Krishnan](https://forum.inductiveautomation.com/u/Bharat_Krishnan)\
**Post date:** [November 14, 2023, 8:47pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/1 "2023-11-14T20:47:05Z")

</div>

I am trying to render a view to the table cell. I have posted the screeenshots of how the value fro viewParams is set up and how params are bound to the view that i am using to render the cell.

 ![2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/86dfb91f9dff2a8fbd3cefb2f89a4d15fb5a1282.png)  
 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b435546f504ecc52af329ab2b5f2e77787a73911.png)  
if there is any other information that i can provide regarding the script or the table.Is this the right way to approach this

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 14, 2023, 8:56pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/2 "2023-11-14T20:56:38Z")

</div>

The data structure expected by your sub-view is:

```auto
FFT : xxx
value
  key
    count : x
    timestamp : xx:xx

```

The data being supplied in the table cell's viewParams doesn't match:

```auto
FTT : xxx
value
  TOTAL REPAIRS
    count : x
    timestamp : xx:xx
  PTR SOCKET WELD
    count : x
    timestamp : xx:xx
  H5985
    count : x
    timestamp : xx:xx

```

As a result, I suspect, the rendered view has no parameter values to use other than 'FFT'.

---

<div class="post-metadata">

**Author:** ![Bharat\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Bharat\_Krishnan](https://forum.inductiveautomation.com/u/Bharat_Krishnan)\
**Post date:** [November 14, 2023, 9:17pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/3 "2023-11-14T21:17:59Z")

</div>

how should i change the data -structure inorder to make it similar to table cell's viewParams

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 14, 2023, 9:19pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/4 "2023-11-14T21:19:42Z")

</div>

It depends how you are generating it. Show us how. If it's a script then post formatted code (using the \</\> button).

---

<div class="post-metadata">

**Author:** ![Bharat\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Bharat\_Krishnan](https://forum.inductiveautomation.com/u/Bharat_Krishnan)\
**Post date:** [November 14, 2023, 9:23pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/5 "2023-11-14T21:23:50Z")

</div>

```auto
def transform(self, value, quality, timestamp):
	columns = []
	data = self.props.data
	header = {}
	defects = {}
	unique_products = set()
	
	# Additional data structure for storing latest timestamps
	latest_timestamps = {}
	
	for row in value:
	    product = row['PRODUCT_CODE']
	    if row['RESULT'] != 'PASS':
	    	timestamp = system.date.fromMillis(row['TIMESTAMP'])
	
	    if product not in unique_products:
	        obj = {"field": product, "render": "view", "justify": "center", "viewPath": "COMMON RESOURCES/MACHINES/FUSION/cell"}
	        view_params = {"FTT": None, "value": {}} # Initialize view_params
	
	        for i in data:
	            defect = i["DEFECT"]
	
	            if defect not in defects:
	                defects[defect] = {}
	                latest_timestamps[defect] = {}
	
	            if defect == "FTT" and row["PRODUCT_CODE"] == product:
	                ftt = i[product]
	                view_params["FTT"] = ftt
	            else:
	                current_timestamp = latest_timestamps.get(defect, {}).get(product, None)
	                if current_timestamp is None or timestamp > current_timestamp:
	                    defects[defect][product] = i[product]
	                    current_timestamp = system.date.format(timestamp,"HH:mm")
	                    latest_timestamps[defect][product] = current_timestamp
	                view_params["value"][defect] = {"count": defects[defect][product], "timestamp": latest_timestamps[defect][product]}
	
	        obj["viewParams"] = view_params
	        columns.append(obj)
	        unique_products.add(product)
	
	
	
	# Adding obj1 at the beginning
	obj1 = {"field": 'DEFECT', "justify": "center", "width": 300, "strictWidth": True}
	columns.insert(0, obj1)
	return(columns)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 14, 2023, 9:37pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/6 "2023-11-14T21:37:52Z")

</div>

You need to define what exactly you want displayed in each column. Since the view parameters can only support  
`{"value": {"key": {"count": x, "timestamp": xx:xx}}}`  
you can only pass through that data arrangement. Your code is creating dictionaries for each defect type it finds but your view doesn't support that arrangement.

Is this someone else's code that you are modifying? The question seems odd if it's your own.

---

<div class="post-metadata">

**Author:** ![Bharat\_Krishnan](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Bharat\_Krishnan](https://forum.inductiveautomation.com/u/Bharat_Krishnan)\
**Post date:** [November 14, 2023, 11:46pm UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/7 "2023-11-14T23:46:34Z")

</div>

the problem with the data is that the defects change every day. The keys with defect names changes but i wont be able to set that up for value param in the view. because the keys are not known beforehand. So i was asking for help to how to structure the data in the table columns viewParams so that i can read those values. Any ideas?I am not familiar with the way table columns take in the value of the viewParams.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 15, 2023, 8:32am UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/8 "2023-11-15T08:32:07Z")

</div>

I never worked out how (or if you could) do what you're trying to do. I had to create a `params.rowData` object with all of the params to pass in in there. The table then automatically passes all of the column values into that object

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 15, 2023, 9:32am UTC](https://forum.inductiveautomation.com/t/rendering-a-view-to-a-table-unable-to-bind-the-view-params/81895/9 "2023-11-15T09:32:22Z")

</div>

The view you have created to embed can display one numeric value and a timestamp. What do you want to display when you have three defects as shown in your sample data?

Mock it up in Excel and post a screenshot.
