I'm using the DevExpress xtraChart to display some data. In the CustomDrawSeries event, I'm checking the series name and changing SeriesTemplate.Label.PointOptions.ValueNumericOptions.Format. It works... partially.
The idea is to change ValueNumericOptions.Format from NumericFormat.FixedPoint to NumericFormat.Percent and vice versa based on the name. The problem is the change is not displayed immediately. In order to see the change, the user must select another cell and then the change is visible immediately.
How can I force a refresh to the series and see the changes immediately without needing to select another cell?
Update -
After the change is made via code, I inspected Format and it is being set correctly. This confirms, in my mind anyway, this is a refresh issue.
I do not know what the real cause of the problem, but your approach seems to be not quite optimal. You modify the global settings (template) while your goal is just to change settings for a certain series.
What you want to achieve can be done during the ChartControl initialization, without having to handle events. The following code can be used to apply a percent format to a certain series:
DevExpress.XtraChartsPointOptions pointOptions = new DevExpress.XtraChartsPointOptions();
pointOptions.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Percent;
DevExpress.XtraCharts.SideBySideBarSeriesLabel label = new DeveExpress.XtraCharts.SideBySideBarSeriesLabel();
label.PointOptions = pointOptions;
DevExpressXtraChartsSeries series = xtraChart1.Series["Series Name"];
series.Label = label;
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
By the sounds of it you are registering to the Refresh event of the view controller which will change the format of the chart on refresh, assign your code also in the OnViewControlsCreated event to initialize your code upon first creating the view.
Related
I don't understand how to make the Client ui aware of a server side change in a document.
My use case is the following : I'm adding a button to my form, that calls a custom document method :
In MyDocType.py, I have :
class MyDocType(Document):
#frappe.whitelist()
def change_some_value_in_doc(self):
self.the_field_i_want_to_change = 50
It work in the sense that the_field_i_want_to_change is immediately updated to the new value.
However, If I hit Save, I get the message "No changes in document". I managed to determine that this is because on the JS side, the form is not marked as "dirty", but despite reading the documentation over and over, I cannot find the right way.
I tried with self.notify_update() which seems to have no effect.
Is it a bug ? Or am I misunderstanding how this is supposed to work ?
I'm using frappe v 14.0.0-beta.3
[EDIT]
Actually, I realized that doing
class MyDocType(Document):
#frappe.whitelist()
def change_some_value_in_doc(self):
self.the_field_i_want_to_change = 50
self.save()
Does work in the sense that it save the new value, but it's not exactly what I'm looking for, because my purpose is actually to pre-fill some data with the custom method and leave to the user to complete before saving...
Any help to get me in the right direction would be very appreciated.
To pre-fill data in your form - that you want the user to confirm before saving to the database, you should use client-side scripting (in JS). Changing the value on the server is not going to help you since you want the user to get pre-filled values before inserting a record in the database.
I'm using date.ftl to display date and time in Alfresco Share 4.2c, with parameter showTime set as true. Default time is 00:00. Is there a way to set current local time as the default time?
Is it better to try to change that in date.ftl or maybe in some associated .js file?
I was looking, but I couldn't find where it is set, so any help will be appreciated.
Changing existing date.ftl is not advisable.Instead of that you should create your own date control(you need to create both ftl and as well as javascript file),In that you need to change below things.
Change in tomcat\webapps\share\components\form\date-picker.js file(this should be file which you have created for your custom control).In onReady() function set the value of text box using javascript.
We have a REST Service and Dojo DataGrid that does not save the changes to editable columns on the initial load -- meaning the XPage loads and changes are made. The only way the changes are saved is after the close() or revert() method for the REST service is called, then the save() method is called. The REST Service is pointing to another database on the same server, and uses the keys property:
<xe:restService id="rsVictims" pathInfo="rsVictimsData">
<xe:this.service>
<xe:viewItemFileService defaultColumns="true"
viewName="InvoiceGridVictims" contentType="application/json"
databaseName="voca\vocadatastore.nsf" keys="k28ts71zrjsw">
</xe:viewItemFileService>
</xe:this.service>
</xe:restService>
Here is the DataGrid:
<xe:djxDataGrid id="djxDataGrid1" storeComponentId="rsVictims"
autoHeight="90">
<xe:djxDataGridColumn id="djxDataGridColumn1"
label="Target" width="35px" field="victimTarget">
</xe:djxDataGridColumn>
<xe:djxDataGridColumn id="djxDataGridColumn2"
label="Oct" width="35px" field="month_10" editable="true">
</xe:djxDataGridColumn>
</xe:djxDataGrid>
It flows like this:
Open the XPage with the REST service and DataGrid
Make changes to the editable columns
Click the Save button which calls this code (code is copied from Brad Balassaitis' demo, 06 Custom Control):
<xp:button value="Save Changes" id="victimsSaveButton">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[// Save the changes...
editedRows = [-1];
var args = {onError: function() {alert('error!');}};
rsVictims.save(args);
//Refresh the grid
rsVictims.close();
dijit.byId('#{id:djxDataGrid1}')._refresh();]]></xp:this.script>
</xp:eventHandler>
</xp:button>
DataGrid is closed, refreshed, but changes are NOT saved
Make changes again and click the Save button
DataGrid is closed, refreshed, and changes are now saved
What I have noticed is that the DataGrid is loaded twice when the XPage is opened -- I see this is Firebug in the Net tab. On the first GET, it retrieves the grid correctly -- the Response is correct, the JSON is formatted correctly, and the start=0 with a count=25.
On the second GET, it seems to lose the grid -- the Response is empty, the JSON items is empty, and the start=25 with the count=25. I have tried setting the start property in the REST Service to 0, but that does not do anything. I have tried setting the count property to 500 as well, but that does not fix it either.
The interesting fact about this is, when the view is moved inside the current database -- so the databaseName property on the REST Service is not used -- the Save button works perfectly. Also, there is only one GET when loading the DataGrid, not two GETs when pointing to a view in another database on the same server. I know there are some issues when looking to another server, but these databases are on the same server.
I know I have posted about this topic before, but I did not get an answer that worked. I am hoping this sheds some more light on what I may be missing.
Thanks in advance!
Dan,
I have nearly an identical situation in my current project. I have mine working perfect so I think I can help. I assume that you already took Per Lausten's suggestion in your previous SO. You wouldn't be able to save at all if you didn't.
The difference between your code and mine is that I am using a xe:viewJSONService instead of a xe:viewFileItemService. The extention library book says that you have to use the viewFileItem if you want it updatable, but this is NOT true.
I had nothing but trouble with the viewItemFileService, see this blog post for the issues I had (http://notesspeak.blogspot.com/2013/07/going-with-extjs-grid-and-giving-up-on.html) I nearly gave up entirely on the dojo grid, but came back to it because it works on mobile.
Using the viewJSONService just works. Instead of a keys property, use the category filter. For you category have code similar to this:
var category:String = lineItemBean.getThisUNID();
if(category == null){
return "show nothing"
} else {
return lineItemBean.getThisUNID();
}
//prevents all records from being returned
You need to be careful, because if the category is null, all records are returned, which could be a big problem or security hole. In my example, I pull from a bean, but you could put a document reference there as well.
I have a session variable in my asp.net application. The session variable holds a value from the database, that reflects a customized HTML color value.
In my application, I have an asp button with server side code
btnContinue.BackColor = System.Drawing.Color.FromName(Session("ContinueColor"))
Issue: However, when I run the application, the color value is not being reflected in the button.
I did double check, and the session variable does hold the correct value.
There are other objects, that use session variables to display colors, and they are working fine.
How can I resolve this issue?
Update: When I force a color "btnContinue.BackColor = Drawing.Color.Blue", that works perfectly fine.
If it's a hex code, you might want to use ColorTranslator instead:
btnContinue.BackColor = System.Drawing.ColorTranslator.FromHtml(Session("ContinueColor").ToString());
Looking at the color information you posted in your comment, I think you just need to cast the session object as type Color:
btnContinue.BackColor = DirectCast(Session("ContinueColor"), System.Drawing.Color)
EDIT
I found the solution:
btnContinue.BackColor = System.Drawing.Color.FromName("{Name=48E8DD, ARGB=(0, 0, 0, 0)}")
In your case, it would be:
btnContinue.BackColor = System.Drawing.Color.FromName(Session("ContinueColor").ToString())
Which part of the page life cycle are you setting the color? Maybe the session data has not been read yet? Session should be ready after PageLoad.
I recommend setting a break point immediately after this line of code to make sure nothing else is overriding it - theme.
btnContinue.BackColor = System.Drawing.Color.FromName(Session("ContinueColor"))
I don't understand how QTable::editCell() should be used. I am trying to do some error checking based on entries made by user in a QTable as mentioned in my another question.
I would like to give user an opportunity to re-edit the cell which has error. For example, if name column entry has some special characters such as '(', the user should be prompted for the error and the control should go back to same cell in edit mode. I tried using QTable::editCell() in my code as shown below.
Table->editCell(row, 0, TRUE);
name = Table->text(row, 0);
However, this doesn't work as expected. The control doesn't stay in the cell at all and obviously the name is not correctly collected. So, my question is how to ensure from within code that a cell of QTable can be edited so that the edited contents can be accessed immediately in next statement (as shown in above code).
Note: I am working with qt 3.3.8 only.
I don't think you can do that. You'll have to go back to the event loop, and wait for one of the signals (like valueChanged(row,col)) to be fired to re-validate the data.
A blocking wait on a GUI object is often not a good approach (except for modal dialogs).
I know I'm a little late here but you should use the following connect statement with your own custom function to do your specific needs such as below. You can also use this method to disable users from entering in special characters within you custom function. That way they wont ever have to correct undesirable characters.
connect(ui->tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(customFunction(int,int)));
void updateTable
{
//remove invalid characters
}