Hi
Is it possible to pass a variable value from invoke-udjavascript into ud to use it with set-udelement?
Or is there a way in ud i can get the text value in a grid cell ?
Hi
Is it possible to pass a variable value from invoke-udjavascript into ud to use it with set-udelement?
Or is there a way in ud i can get the text value in a grid cell ?
Can you share a little code of what you are trying to do?
I have a udgrid that outputs text in a grid cell and a button in the cell to its right
i want to be able to click the button and grab the value of the grid cell then put that value in and another element
since the grid cell doesnt have an id seems i can get its value using js previousSibling.innerText then use setattribute to put the value in the input element but even though the value is displayed in the input ud doesnt recognize that there is data in the input so when i try to run a ud scriptblock using the value i get errors that the value is null or empty, only way to get ud to recognize the value is to type something in the input field or what im thinking is to use set-udelement to add the value
so if i could pass the variable i set using invoke-udjavascript into ud to use with set-udelement or just grab the value from the grid cell id be good
not sure this is possible though thanks
$output.Add([PSCustomObject]@{
Device = $device
More = New-UDButton -text "More" -OnClick {
Invoke-UDJavaScript -JavaScript "
document.getElementById('results').onclick = e => {
var test = e.target.previousSibling.innerText;
console.log(test);
//set variable
var inputbox= document.getElementById('inputbox');
//below will put the test variable value in the inputbox element but ud doesnt recognize the element value so cant run ud scriptblock on value
//is there a way to use the test variable value with set-udelement
inputbox.setAttribute('value', test);
} "
}
})
Sync-UDElement -Id "results"
}
If you are trying to get the device value, you can just use that variable in your OnClick Handler.
$output.Add([PSCustomObject]@{
Device = $device
More = New-UDButton -text "More" -OnClick {
Show-UDToast $Device
}
})