Gridcontrol edit/update mandatory fields different colour - vb.net

I'm just wondering how can I change background colour of mandatory fields while adding new row.
So for example name and surname would be red (mandatory) and phone would be default white.
Thank you
Patryk

The best way to do this is through the grid's designer -- in most cases you don't need to write any code to accomplish this.
If you go to the Grid View designer, select the menu item "Appearance" and "Format Rules:"
From here, you can add a format condition by clicking the plus icon:
Under "Column," pick the column you want the format condition to apply to.
Under "Rule," pick an appropriate rule -- based on what you described, you probably want "Format Based on a Value," FormatConditionRuleValue.
On the "Rule" tab of this same dialog, you can set your "Value1" and "Condition" properties accordingly, for example Value1 = 15, Condition = "equals."
The "Appearance" property will let you determine how to format the cell based on these conditions.
The beauty of this approach is it's all designer-based code, and it's very easy to customize. The logic behind the formatting is also very transparent. The format conditions have been expanded to let you evaluate expressions as well, meaning you can create your own formulas using other column values and functions.
If all else fails, you can use the RowCellStyle event, but my first attempt would always to be to use the designer tools.

You can use an event gvView_CustomDrawCell and set background color only if the line is in state that you need (Added, Detached ...)
private void gvView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column != null && (e.Column.Name == bgcName.Name || e.Column.Name == bgcSureName.Name))
{
DataRow focusedRow = gvView.GetDataRow(e.RowHandle);
if (focusedRow != null)
{
if (focusedRow.RowState == DataRowState.Added)
{
e.Appearance.BackColor = Color.FromArgb(80, 10, 30, 200);
}
}
}
}
asd

Related

How to set custom colors for Odoo 12 calendar view events?

There is a good tutorial on how to achieve this in Odoo-8 here:
Tutorial , but it doesn't work on Odoo-12.
Odoo natively allows you to set a field of your model as a basis for color differentiation in calendar view.
<calendar ... color="your_model_field">
The problem is that he will decide automagically what color to assign to every value.
I need to be able to decide what color mapping to use.
Doing some diving in the web module js files, more specifically on
web/static/src/js/views/calendar/calendar_renderer.js on line 266
I found a promising function which appears to be the one responsible for deciding which color to set.
getColor: function (key) {
if (!key) {
return;
}
if (this.color_map[key]) {
return this.color_map[key];
}
// check if the key is a css color
if (typeof key === 'string' && key.match(/^((#[A-F0-9]{3})|(#[A-F0-9]{6})|((hsl|rgb)a?\(\s*(?:(\s*\d{1,3}%?\s*),?){3}(\s*,[0-9.]{1,4})?\))|)$/i)) {
return this.color_map[key] = key;
}
var index = (((_.keys(this.color_map).length + 1) * 5) % 24) + 1;
this.color_map[key] = index;
return index;
},
This function is fed the value of your field (for every calendar event) and returns the color to be used "supposedly" as background for the calendar event square.
According to the second if statement, if you manage to instantiate the CalendarRenderer class with a color_map object which has the possible values of your field as keys and color codes as values you should be ok.
According the the third if statement, if the values of your field are strings with color codes (#FFF, rgb(x, y, z) , etc) they will be set in the color_map object and returned to be used as background colors.
The last part I guess is how odoo decides on a color when no mapping is provided.
I tried both approaches with the same efect:
Image displaying the calendar view
Namely, all the calendar events are rendered with the default color taken from the fullcalendar.css stylesheet (line 529), but the color reference displays correctly on the sidebar to the right.
I would appreciate any light shed on this matter, It has to be possible to make this work!.
Thanks.

Modifying column header names in Master-Detail grid in Devexpress

I have a Master-Detail set up with 2 grids. On the master grid, I have the ShowOnlyPredefinedDetails option set to false.
This means that I see a little + sign that allows me to expand the details of the detail grid (in the master grid). I would like to rename
some columns in that section as well as hide certain columns. I'm using VB.NET How do I go about this. See image.
You can accomplish this by using the grid control ViewRegistered event, from there you can modify the columns in that grid view that have columns within them that you want to modify, rename, or remove. Here is an example, I hope that it helps:
private void myGridControl_ViewRegistered(object sender, DevExpress.XtraGrid.ViewOperationEventArgs e)
{
if (e != null)
{
if (e.View != null)
{
//Inside of this statement you can adjust, add, and modify all of the columns inside of that grid that appears when you click on the +
(e.View as GridView).Columns["myHiddenColumn"].Visible = false;
(e.View as GridView).Columns.Add(new GridColumn() { Name = "AddColumn", Caption = "Name To Display", Visible = true, FieldName = "DataField"});
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowEdit = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.AllowFocus = false;
(e.View as GridView).Columns["DataField"].OptionsColumn.ReadOnly = true;
}
}
}
I think all you need to do is create a second grid view for your details. If you haven't already done this, do the following:
In your grid designer, click "Retrieve Details" if you have not already done so. This will cause the designer to recognize that you have a second level in your bound object:
Once you see the second layer, now you need a new grid view for it. Click on "Click here to change view" and select "Create a new view" and pick "GridView."
Now you will see both grid views from the designer, and clicking on one or the other will change the context of the menus to the left:
For example, if you have gridView2 selected, when you click on the "Layout" menu, it will show the current layout for your detail grid rather than the master grid. From here, you can remove or add columns as you see fit. Likewise, from the "Columns" menu you will see the new columns (you may have to add them to the view by dragging them over), and you can change the Caption property to change the text of the title.
I suggest you use the Data Annotation attributes with properties of your data-classes to declare how you data should be displayed in GridControl:
To skip column generation for the specific property you can mark this property with the <DisplayAttribute(AutoGenerateField := false)> declaration.
To prevent column from displaying you can mark this property with the <DisplayAttribute(Order := -1)> declaration. Later, user can show this column via Column Chooser UI.
To specify the column caption use the <DisplayAttribute(Name := "YOUR CAPTION")> declaration.
You can also control filtering/editing/formatting and validation capabilities.
Related Links:
Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes
Video Tutorial: Create and Manage Data in Code and Apply Data Annotation Attributes

On demand color set of rows in SmartClient (TreeGrid)

I have a TreeGrid in SmartClient. Now I want to color some set of lines like line numbers 3-5, 7-11 etc. I am using an external button which passes the values to the SmartClient. Can anybody tell me how to do that? A button is passing the value and it's working fine. But the problem is, where to get the value in SmartClient and how can I color that set of lines.
Since TreeGrid is a ListGrid, I would imagine you could override the getCellStyle function and set the colors as you see necessary.
http://www.smartclient.com/docs/8.1/a/b/c/go.html#search=getcellstyle
So basically in pseudo code:
if (row >= 3 and row <=5)
return "style1"
if (row >= 7 and row <=11)
return "style2"
else
return this.baseStyle
where style1 and 2 are defined in css
And how to custom and keep states with using specific style name (myStyle) like :
myStyle
myStyleDark
myStyleOver
myStyleOverDark
myStyleSelected
myStyleSelectedDark
myStyleSelectedOver
myStyleSelectedOverDark
myStyleDisabled
myStyleDisabledDark
I try to use #Override of getCellStyle
for returning "myStyleA" or "myStyleB"
which i want conserve dynamics suffixs : "Dark", "Over", "Selected", ...
An idea ?...
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGrid.html
The state of the record is indicated by adding a suffix to the base style.
There are four independent boolean states, which are combined in the order given:
"Disabled" : whether the cell is disabled; enable by setting the "enabled" flag on record returned by getCellRecord
"Selected" : whether cell is selected; enable by passing a Selection object as "selection"
"Over" : mouse is over this cell; enable with showRollovers
"Dark" : alternating color bands; enable with alternateRowStyles

How to change font color of a dojo DataGrid row after a cell has been edited

I want to change the font color of a row after a cell in that row has been edited and set to a certain value.
myStore is the dojo.data.ItemFileWriteStore associated to the dojox.grid.DataGrid dataGrid.
I have written this:
myStore.onSet = function(item, attribute, oldValue, newValue) {
if (item.myField == myValue) {
var index = dataGrid.selection.selectedIndex;
dojo.style(dataGrid.getRowNode(index), "color" , "red");
}
}
but unfortunately this doesn't make any effect...
UPDATE: I added the following style property: "backgroundColor" : "red". Well, the background color of the row changes to red, but when the mouse moves away from the row, the color changes back to the default! It might be that some default event handlers restore the default styles...
The dojo.style line works if you call it by itself. Either your function isn't being called at all, the if's condition false or there is no row selected and you are getting an invalid number for the index. (You can put some console.logs there to check)

Wix: How can I set, at runtime, the text to be displayed in VerifyReadyDlg?

After the user goes through the Setup Wizard, and makes a few choices, the usual thing is to display the VerifyReadyDlg to say "Are you ready to install?"
The built-in VerifyReadyDlg is static. It does not present a summary of the choices he made previously. I'd like to modify it so that it does.
How can I do that?
Example
"Static" text:
Intelligent text:
I don't believe I can modify the Control table in the MSI, because mods during the installation process are not allowed. I found MsiViewModifyInsertTemporary, but I don't think that will work either. The relevant row in the Control table is already present, and it contains static data. I want to modify the data, just before VerifyReadyDlg is displayed.
You may not be able to modify existing rows in the MSI tables, but you can insert new "temporary" rows.
So, in a custom action, at runtime, insert one or more temporary rows into the Control table. In Javascript, it looks like this:
var controlView = Session.Database.OpenView("SELECT * FROM Control");
controlView.Execute();
var record = Session.Installer.CreateRecord(12);
record.StringData(1) = "VerifyReadyDlg"; // Dialog_ - the dialog to mod
record.StringData(2) = "CustomVerifyText1"; // Control - any unique name will do
record.StringData(3) = "Text"; // Type
record.IntegerData(4) = 25; // X
record.IntegerData(5) = 70; // Y
record.IntegerData(6) = 320; // Width
record.IntegerData(7) = 65; // Height
record.IntegerData(8) = 2; // Attributes
record.StringData(9) = ""; // Property
record.StringData(10) = text1; // Text - the text to be displayed
record.StringData(11) = ""; // Control_Next
record.StringData(12) = ""; // Help
controlView.Modify(MsiViewModify.InsertTemporary, record);
controlView.Close();
You probably want that custom text to be displayed only upon INSTALL. In that case, add a condition, in the same way:
var controlCondView = Session.Database.OpenView("SELECT * FROM ControlCondition");
controlCondView.Execute();
record = Session.Installer.CreateRecord(4);
record.StringData(1) = "VerifyReadyDlg"; // Dialog_
record.StringData(2) = "CustomVerifyText1"; // Control_ - same name as above
record.StringData(3) = "Show"; // Action
record.StringData(4) = "NOT Installed"; // Condition
controlCondView.Modify(MsiViewModify.InsertTemporary, record);
controlCondView.Close();
The Msi constants are defined like this:
// http://msdn.microsoft.com/en-us/library/aa372516(VS.85).aspx
var MsiViewModify =
{
Refresh : 0,
Insert : 1,
Update : 2,
Assign : 3,
Replace : 4,
Merge : 5,
Delete : 6,
InsertTemporary : 7, // cannot permanently modify the MSI during install
Validate : 8,
ValidateNew : 9,
ValidateField : 10,
ValidateDelete : 11
};
A couple notes:
The InstallText in the Control table is normally displayed. It can be customized with a .wxl file, inserting something like this:
<String Id="VerifyReadyDlgInstallText">Whatever.</String>
This results in a row in the Control table. But you cannot remove rows from the table at runtime.
If you choose the X,Y and Height,Width for your new custom text to be the same as for the static InstallText, the InstallText will be obscured.
It may seem counter-intuitive to use "NOT Installed" as the condition - but remember, this is the state of the world prior to running the Setup Wizard. If the MSI is Installed prior to running the Wizard, then you're probably not installing it, which means you don't need to display the choices being made in the wizard.
Of course you can add multiple controls this way. You could add multiple Text controls, or...You can add lines, buttons, checkboxes, whatever. For each one, you'll have to set the control type and geometry appropriately. Use Orca to examine the Control table to figure out how.
This approach works for any Dialog. You only have to be sure to run the custom action to insert the temp rows into the Control table, at some point in the InstallUISequence, before the Dialog is rendered.