disable *some* checkboxes in a column in a GXT Grid - gxt

I have a GXT Grid showing some "User" objects. One of the columns holds checkboxes (CheckboxCell) . I need to disable a checkbox for 1 particular user and leave others enabled.
I tried extending CheckboxCell class - it's useless because it does not know the context (which User is renders): it only knows about true/false state.
tried
GridView view = table.getView();
Element cell = view.getCell(0, 1);
cell.setAttribute("disabled", "disabled");
-no luck. the disabled attribute is set on the outer "td" tag instead of the child "input" element.
tried cell.getChild..() methods - they all throw "method does not exist" exceptions.
UPDATE: I ended up creating my own CheckboxCellWhichCanBeDisabled class extending AbstractEditableCell. I'm afraid there's no other way.

Related

Why default lines for One2many fields are not filling in related and default values automatically in Odoo 13?

I have a button in the model sale.order with executes the method action_open_certification_views. This method opens the sale.certification tree view. So the method returns the dictionary of the action which opens the sale.certification views, and I have added the following context to auto-fill in the sale.certification fields (sale_id and line_ids, where line_ids is a One2many field pointing to sale.certification.line):
def action_open_certification_views(self):
...
action['context'] = {
'default_name': 'My Certification',
'default_sale_id': self.id,
'default_line_ids': [
(0, 0, {
'quantity': 5.0,
'sale_line_id': line.id,
}) for line in self.order_line
],
}
return action
When I click on the button, the sale.certification tree view is opened right, and if click on Create button, the context of the action is working well since I see the sale.certification form filled in automatically with the default name My Certification, the right link to sale order, and the same number of certification lines as sale order lines has the sale order. Each of this certification lines has quantity 5.0, and the link to sale order line is right too.
The problem is that the sale.certification.line model has many other fields which are related or which have default values, but these certification lines filled in by default by the action context are not filling in those fields.
For example, there is another field quantity2 in sale.certification.line model, and visible in the view, which always takes by default 1.0. However, the field is empty in all default lines. Same problem with related fields. There are some related fields in the view which take their values through sale_line_id field. These one is filled in OK, but the related fields remain empty. For example, in `sale.certification.line model there is this field:
product_uom = fields.Many2one(
related='sale_line_id.product_uom',
)
In spite of having sale_line_id filled in OK in all lines, they have product_uom empty. Can anyone tell me why? Do I have to specify their values in context too, despite they should have been filled in by theirselves?

IcCube - Leaves in Pivot table

If I have a parent-child-dimension, whose data I show in the IcCube/PivotTable and I want to show the leaves only (with descendants([categories].[categories].[All-M],,leaves)), those leaves are shown hierarchically. So a level5 leave of one category is suddenly the parent of a level6 leave of the next category.
Is there a way to "flatten" this tree, so that those leaves are all shown on one level and not sorted in the tree wrongly?
EDIT:
Here is a query:
SELECT
NON EMPTY { [Measures].[group_quality] } ON COLUMNS,
NON EMPTY { TopCount(descendants([categories].[categories].[Level$0].[Portal],,leaves),30,[Measures].[revenue_potential]) } ON ROWS
FROM [Cube]
All categories in the picture are leaves, so none of them has any children.
As workaround for that case you can use simple CSS dirty-hack.
1) First of all under Widget option tab of your widget you should set Hide icons to yes.
2) After this, to avoid collision with other Pivot Tables, add custom CSS class
3) Add these styles to Report CSS.
.pt-flattened .pt-hcont{
margin-left: 0 !important
}

How to style a specific list item in lwuit?

I am need of a requirement that in a list, some of the list item should exhibit different style than others. How can this be achieved in lwuit?
For Example,
List menu = new List();
menu.addItem("1. Green");
menu.addItem("2. Red");
menu.addItem("3. Blue");
In this list Each item should have the style of representing its color(i.e) Green should have green Background and Red should have Red Background. Is it possible in LWUIT? How can we achieve this?
Thanks in Advance.
You must create a cell renderer for this use case. Just derive 'DefaultListCellRenderer' e.g.:
DefaultListCellRenderer rend = new DefaultListCellRenderer() {
public Component getCellRendererComponent(Component list, Object model, Object value, int index, boolean isSelected) {
Component c = super.getCellRendererComponent(...);
c.getStyle().setBgTransparency(255);
c.getStyle().setBgColor(theColorYouWant);
return c;
}
};
Then set this renderer to the list. You will probably need some additional refinements here since this is a WAY oversimplified example of a renderer.
This is one way of doing it.
1. Create a component for each item in the list
2. Add the bg color and text to it.
3. Once done, add it to a form or any other custon component you have created.
Other way:
You can create your own List renderer. Here is some information on how you can do it

SharePoint: Problem with Custom Field EntityEditorWithPicker

I have a custom field derived from SPTextField displays EntityEditorWithPicker while in New or Edit mode (I have extended my class from EntityEditorWithPicker). I have added that field as column to a list. When I select any item from the Dialog, it adds that item to the list column. Fine till here. Fine upto this point.
But when I go to Edit any item in the list, it shows the EntityEditorWithPicker on the edit item page but textfield is empty. I want that the value in the list should appear in the textfield in the EntityEditorWithPicker. How can I achieve that.
Thanks in davance for the help.
Best regards,
Asher
We have UpdateEntities() method in EntityEditorWithPicker class (Please note that we need to extend this class for use in our code) that accepts the object of ArrayList. Create EntityPicker Object, populate the Key property (Key property will appear in the Textbox as you want), add EntityPicker object in ArrayList Object and then pass ArrayList Object to UpdateEntities() method. We are done!!!
MyExtendedEntityEditorWithPicker _recordPicker = new MyExtendedEntityEditorWithPicker();
ArrayList entities=new ArrayList();
EntityPicker entity=new EntityPicker();
entity.Key="Value To be Displayed in Textbox";
entities.Add(entity);
_recordPicker.UpdateEntities(entities);
I hope this helps!
Azher Iqbal

Cascading list boxes, with multi-select

I wound up modifying the source from a publically posted POC: http://datacogs.com/datablogs/archive/2007/08/26/641.aspx, which is a custom field definition for cascading drop downs. The modifications were to allow parent-child list boxes where a user can multiselect for filtering and selecting the values to be written back to a SharePoint list. I got the parent-child cascading behavior working, but the save operation only takes the first value that is selected from the list box. I changed the base type for the custom field control from "SPFieldText" to "SPMultiLineText", along with changing the FLD_TYPES field definition values from:
Text to Note and this did not work. So, I changed the field control base type to "SPFieldMultiChoice" and the FLD_TYPES to "MultiChoice" and still get the same result, which is only the first value that's selected, writing to the SharePoint list.
Does anyone have any idea how to get a custom field with multiple selections to write those multiple selections to a SharePoint list?
Thanks for taking the time to read through my post.
Cheers,
~Peter
I was able to accomplish this by inheriting from SPFieldLookup and overriding its internal handling of AllowMultipleValues:
In your FLDTYPES_*.xml set <ParentType>LookupMulti</ParentType>
In your extension of SPFieldLookup, be sure to override AllowMultipleValues (always true), FieldValueType (probably typeof(SPFieldLookupValueCollection)) and FieldRenderingControl. I also set base.LookupField = "LinkTitleNoMenu", though in retrospect I'm not sure why. :)
In your field editor control's OnSaveChange(), set the field's Mult value to true.
To set Mult, you can either string manipulation on field.SchemaXml:
string s = field.SchemaXml;
if (s.IndexOf(" Mult=", StringComparison.OrdinalIgnoreCase) < 0)
field.SchemaXml = s.Insert(s.IndexOf("/>", StringComparison.Ordinal), " Mult=\"TRUE\" ");
Or use reflection:
var type = field.GetType();
var mi = type.GetMethod("SetFieldBoolValue", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(field, new object[] { "Mult", true });
It's been a while, so I might be forgetting something, but that should be most of it.

Resources