01-31-2018 09:45 AM
If you switch to the html tab in NXG, you will see that NI is using javascript everywhere.
So if you know javascript, you are one step ahead of others.
I'm not expert in javascript, just start to learn a couple weeks.
Here is what I did to add a ring ctrl to html:
In the html file, in the <body>, after NI's javascript, i.e. after
<div class="ni-front-panel-wrapper">
<section id="FrontPanelCanvas" class="ni-front-panel">
......
</section>
</div>
Add:
<div class="UserList">
<select id="Users" Label="Users"></select><br>
</div>
You can use a seperate .css file the define the font name, size, color, ctrl size and position to minimize the change the html file. To link the .css file, add:
<link href="my.css" rel="stylesheet" type="text/css">
in the <head> after NI's links.
To update the ctrl, create a seperate .js file, and add:
<script src="my.js"></script>
in the <head> after NI's scripts.
In the .js file, define a javascript variable link to html ctrl:
var userlist = document.getElementById('Users');
Dynamically alter the ctrl style:
userlist.style.width = 160 + "px";
Dynamically add element to the ring ctrl:
var opt = document.createElement('option');
opt.text = "George";
opt.value= 0;
userlist.add(opt, null);
for Listbox, take a look the following site:
https://www.w3schools.com/js/default.asp
Remember to save your change by click the APPLY button.
01-31-2018 10:01 AM
Dynamically add element to the ring ctrl:
That "dinamically" is not clear.
I use a diagram variable how do i pass a variable value to the javascript?
01-31-2018 10:07 AM
01-31-2018 11:15 AM
I haven't figure out how to exchange data with an NXG ctrl yet. Still waiting for NI engineer give us an example.
For now, you can write the data to a JSON file, and then use javascript to load it.
I use jquery to get data from LabVIEW/WebService, like:
$.getJSON("http://127.0.0.1:8001/WebDBService/WebGetUserList", .....);
To load a JSON file, just google: javascript read json file from disk.
So my code won't work if no webservice is available.
02-01-2018 01:10 AM
Ok thank you so much.
For the moment I'm just testing NXG...but too many lack for my use of labview.
No DB connection,Even the HTML editor..no FIND function, no way to exchange data between html and block diagram.
But webVI's seems a nice thing.
For the future I dream about NXG to compile even for mobile.
02-01-2018 07:39 AM
@gepponline wrote:
For the future I dream about NXG to compile even for mobile.
I believe NI's intent is that the solution for mobile will be WebVIs. Compile it to HTML, then share it via a webserver. This does actually work and I've tested it on several mobile browsers on Windows/IOS/Android.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-01-2018 07:41 AM
I thought it so...so let's hope it will develop a solution form my problems early 🙂
02-01-2018 07:42 AM
02-01-2018 09:34 AM
javascript support events.
In my code, when user make a selection on the userlist ring ctrl, I'll call the LabVIEW webservice which pulls the user information from a database:
userlist.onchange = function()
{
...
}
02-01-2018 09:57 AM
ok, but the event should be something like "when the list get populated" or "when the file with the list items is created"