1 year ago
#383173
JAG
Use global variable in json - javascript - aggrid
I'm trying write a function which opens new tab refering to a linked source.
For that I need to send a payload with the id and other parameter which I already have in my grid table (field: "globalId" and field: "id").
I tried to execute the command to get the value, but I'm not able to use variables in the payload load as i get "{x}" as a result, is there any way to retrieve this from the already generated grid table?.
This is the part of the code I'm having issues with:
var x = formData.get().root.id;
function openApplication() {
var postData = {
"action": "openApplication",
"payload": {
"id": "x",
"caseId": "a75659c-36f315678299515",
"name": "test"
}
};
Here is the full code (which has the columns that need to retrieve the values from):
<script type="text/javascript" charset="utf-8">
function DataFromAPI()
{
var url=basepath + '/rest?limit=20&offset=0&q=type:CAS+state:open+ModelId:eq:jlbc421f00f2f+name:eq:'+formData.get().root.name;
httpClient.get(url, function (result) {
gridOptions.api.setRowData(result);
tempData.set('AsearchResult'.result);
});
}
var columnDefs = [
{
field: "Date",
headerName : "Date",
editable: false,
resizable: true,
}
{
field: "id",
headerName : "",
resizable: true
},
{
field: "globalId",
headerName : "",
resizable: true
}
];
function getData() {
const rowData1 = [];
return rowData1;
}
// let the grid know which columns and what data to use
const gridOptions = {
columnDefs: columnDefs,
onRowClicked: event => openApplication(),
defaultColDef: {
editable: true,
rowSelection: 'single',
filter: true,
sortable: true,
flex: 1,
minWidth: 100,
animateRows: true,
}
};
const eGridDiv = document.querySelector('#MeetingGrid');
new agGrid.Grid(eGridDiv, gridOptions);
DataFromAPI();
var x = formData.get().root.id;
function openApplication() {
var postData = {
"action": "openApplication",
"payload": {
"id": "x",
"caseId": "a75659c-36f315678299515",
"name": "test"
}
};
</script>
javascript
html
json
ag-grid
payload
0 Answers
Your Answer