I have a label inside an update panel which I would like to use as a status bar.
Basically the user clicks a button which executes a main function that performs a series of tasks. I'd like to inform the user as to the state of the function as it progresses e.g.:
Stage 1: Retrieving data...
Stage 2: Calculating values...
Stage 3: Printing values...
Stage 4: Done!
I've tried updating the updatepanel directly from the function but it only updates the panel at the end of function (stage 4) and shows "Done!" (which I understand is how it should work).
I've been looking into timers and threads to try and update the panel separate to the main function but I thought I'd post here in case anyone has any better ideas?
Have you put an Update Panel around the label as well? Set UpdateMode to conditional, then when executing your stages, set the label's text then updatePanelProgress.Update() should do it
Related
Good day,
Currently, there are 6 edit boxes, which are connected to specific parameters in the model (and the user can edit these boxes in the model runtime) and a button that doesn't do anything. I want to make this button to restart the simulation, yet if the user previously changed some contents in edit boxes, the new simulation will run based on the user input values. The model name is Simulation.
If anyone knows an example (or specific code) it would be highly appreciated.
Adding to Artem's reply on issue 1: it is actually possible, but you will create a new thread, so a bit advanced. This code will stop the current experiment and restart it:
new Thread() {
public void run() {
getExperiment().stop(); // stops the model
getExperiment().run(); // runs it again
getExperimentHost().setPresentable( getEngine().getRoot() );
}
}.start();
You can make sure to set your params for the new run as Artem discussed.
PS: Would be better to simply make the user press the stop button, feed the values to the experiment page, let the user re-adjust them if needed and let her restart the model as usual.
To clarify, there are two questions:
How to have the button in model that restarts the simulation? - this isn't possible. But what can be done is have a button that calls stopSimulation() and returns the user into the Simulation set up
How to have changes made in model during runtime propagate to the next Simulation run? - save the values from edit fields into internal properties of the model and then access them in Simulation's After simulation run Java action by checking root object
I've created simple application with the DevExpress.XtraCharts.ChartControl. To customize X-axis labels, I used CustomDrawAxisLabel.
But this event occurs twice during creation (once for all labels e.g. from 0 to 10 and one more time from 0 to 10) and 4 times when mouse moves.
How can i get it to occur only single time for all axis labels?
From: CustomDrawAxisLabel Event is fired when moving the mouse over the Chart ?
According to our documentation the
ChartControl.CustomDrawAxisLabel event is raised before drawing a
control. This means that if a control should be redrawn, this method
will be raised first. The parent form can force a control to be
redrawn even if it was not actually changed. In addition, you can
invalidate a control manually by calling the ChartControl method.
Please note that if you use any code that causes chart redrawing (
even indirectly ), this method will be raised, too.
Hope this satisfy your quest for finding for the reason.
I run fairly time consuming calculations in a Shiny app once users have selected input parameters. To make sure the calculations don't run unnecessary times I made the following action button:
actionButton('seeData','see Data' )
I then tried to only have this time consuming calculation run once per button click (and never when there is no button click) with the following code:
observeEvent( input$seeData, {
...long, includes several function calls...
})
Within observeEvent I do reference other input parameters.
What I am finding is that the calculation does not run the first time until I press the button, no matter how many times I adjust input parameters. However, once I press the button once, the calculation runs whenever any input parameter is changed. Why is the code running a second, third, fourth time (etc) when I have only pressed the button once?
My goal would seem to be just the typical use case, but I suppose there is something tricky with an observe or isolate aspect of observeEvent that I am not understanding. What am I doing wrong and how can I achieve one click-one calculation functionality?
use enable() and disable() on the action button.
so when the button is clicked (and before the long calculation) disable the button untill the calculation is done....
then at the end re-enable the button again...
Here we can see a description of the uses of observeEvent and eventReactive. The interesting thing is in the example, where you can see how the reactiveness of the function is performed only in the moment when the button is clicked.
The approach is to define an EventReactive variable which contains the data to be displayed. This will make the function to retain its value even if the input changes. It will only change if the button is pressed.
I have a simple master/details relationship where one order can have multiple revenue allocations. The order has a collection that contains these.
I want to sum a property in my revenue allocation objects and ensure that it adds up to my order total. However, if I databind on the count property of the allocations collection this gets called when you first add an empty object and not when that object has been populated. So an empty allocation is added at the time the "Add allocation" screen is created and the databind function called. That of course means that when the save button on the "Add allocation" screen is clicked, the databind function isn't called again.
Anyone got any ideas? I basically want my databind function to be called when the save button is clicked in the "add screen" and not before.
This is the HTML client - NOT Silverlight
I'm pretty sure that the solution would be to use an OData query to get your aggregate data within the databinding function of the save button - or perhaps a separate button (e.g. "Tally Order Totals"). Exactly how you do that? A bit too hard for me to answer right now, but start with a new button TallyOrderTotals and a new data field for your total. Edit the post_render event for TallyOrderTotals and lookup the allocations in the javascript in which you data bind the value of the new data field.
Somewhere you will need a piece of code that looks something like this:
myapp.activeDataWorkSpace.<datasource>.RevenueAllocations
.filter("OrderID eq " + msls._toODataString(<orderID>, ":String"))
.execute()
.then(function (result) {
// assign the result somewhere
}
I'm not saying that's something you can cut-and-paste - but definitely look at the msls.js documentation and see what you can do with querying your data inside the event context.
One quick point however - if you only need to calculate that total as a verification step, consider doing it in the SaveExecuting() event on the server side. This will allow you to throw an exception back up the tree to your HTML page which the msls.js script should render on the client side.
Hope that helps. :)
How can I refresh view after a certain event?
I have a view which contains multiple groups. I want to show or hide some groups.
onCreationComplete() or initialize() method works only at the beginning of the view creation.
Try invalidateDisplayList() on the view
Let me know if that doesn't do the trick and we'll try some other tricks.
I personally don't like the answer that says to call invalidateDisplayList (sorry no offense Nate nothing personal). I feel it's too vague and doesn't explain what this does under the hood and furthermore you shouldn't have to call it directly in cases such as the one explained in the OPs question. You can simply create booleans that are bindable for each of the groups you'd like to show/hide then in the event handler set those booleans to the appropriate value and if they are bound to the visible and include in layout properties of the containers those containers will internally call invalidateDisplayList after calling set visible and consequently commitProperties.
This is basically what happens under the hood as I understand it: The way this works is values aren't committed or used to update the display until the next frame this way it doesn't get bogged down doing unnecessary layout calculations. So you update the bindable property which fires an event which triggers a notification in the listener (in this case a function that sets the property on your control), that in turn passes along the value to the control which sets an internal flag to update the property and calls invalidateProperties. When it hits the next frame redraw it sees that the properties flag is dirty (true) and then calls commitProperties, this computes/sets the appropriate values (possibly also invalidating then "fixing" the size using invalidateSize() and measure()) and calls invalidateDisplayList, then during the same frame it sees that the display list flag is dirty so it calls updateDisplayList, here it uses the values of the properties to draw appropriately.
You should also be able to achieve this using states, which add or remove children from the display list based on an array of "actions" for each state.