Replies: 3 comments 3 replies
-
|
Hi,
Maybe Sebastien has a better solution |
Beta Was this translation helpful? Give feedback.
-
|
Please share a full and simple example, as providing JS function is fairly trivial. Side note, in the vue template, the Js expression have a different scope and you may need to do some extra work to get your hand on some global/window function/objects. Also do you understand the difference between a static property vs dynamic? str vs tuple in trame. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your responses. I will need some time to prepare an example code. The library that I'm working with is AG Grid. There, it happens a lot that one can pass a function as "renderer" to customize how, for instance, cells should look. one example <template>
<ag-grid-vue :columnDefs="columnDefs" ...other properties>
</ag-grid-vue>
</template>
<script>
//...other imports
import {AgGridVue} from "ag-grid-vue3";
export default {
components: {
AgGridVue
},
data() {
return {
columnDefs: [
{
headerName: "Value",
field: "value",
cellRenderer: params => params.value > 1000 ? "LARGE VALUE" : "SMALL VALUE"
}
]
}
}
//...
}
</script>or gridOptions = {
// register the components using 'components' grid property
components: {
// 'countryCellRenderer' is mapped to class CountryCellRenderer
countryCellRenderer: CountryCellRenderer,
// 'countryFilter' is mapped to class CountryFilter
countryFilter: CountryFilter
},
// then refer to the component by name
columnDefs: [
{
field: 'country',
cellRenderer: 'countryCellRenderer',
filter: 'countryFilter'
},
],
...
}I found a workaround with modifying the main JS file of the component to embed my component, which solves the problem to some extent, but it's not ideal. Especially that the same situation happens a lot with AG Charts and its tooltips. as for the static/dynamic, I assume that the same logic as this slide applies here as well (or?) |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm trying to pass a function to a JS library inside Trame.
I was hoping that Trame will translate the
"function(param){return 'test'}"part to a JS function, but it passes the variable as astring.My assumption was that Trame will evaluate anything inside the quote as a JS expression. I tried other options, including putting the function expression inside another state variable and passing the tuple, but it doesn't get translated as well. Am I missing something here?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions