Gridfield inline editing issue on value - silverstripe-4

We have this GridField with inline editing enabled. But for some reason, the value is showing as plain text in the table.
I found some answer here and suggesting to remove GridFieldDataColumns. But we don't have that component on our Gridfield
$gridfieldPages = new GridField("MenuAddOns","Add Ons",$this->MenuAddOns());
$gridfieldPages->getConfig()
->addComponent(new GridFieldEditableColumns())
->addComponent(new GridFieldDeleteAction())
->addComponent(new GridFieldAddNewInlineButton())
->removeComponentsByType('GridFieldDataColumns')
->addComponent(new GridFieldSortableRows('Sort'));

Related

I created a QToolButton and the label would include "..." but it looks like Qt removes them, is that right?

I use the following code, the first part, creating the QToolButton, is from Designer/moc, the rest I added.
// Moc part
QToolButton * f_tool_button = new QToolButton(bottom_grid);
f_tool_button->setObjectName(QStringLiteral("f_tool_button"));
f_tool_button->setText(QApplication::translate("MainWindow",
"Tool Button...", 0));
// What I added
f_action = new QAction(this);
f_action->setObjectName(QStringLiteral("f_action"));
f_action->setText(QApplication::translate("MainWindow",
"&Click...", 0));
f_menu.reset(new QMenu("Tool Button Menu ...", this));
f_menu->addAction(f_action);
f_tool_button->setDefaultAction(f_menu->menuAction());
If I don't call setDefaultAction(), the title appears as expected.
When I add the default action, the label seems to be replaced by the f_menu title, "Tool Button Menu ..." (I put a somewhat different label on purpose). But somehow the "..." gets removed from the name.
Any idea about this problem? Is that a special Qt feature?
The QToolButton displays text from QAction's iconText property (not text). text is meant to be used in menu entries, whereas iconText is meant to be displayed in tool bars. When not set, iconText is a stripped version of text.
To override the default behavior of stipping text to generate iconText, you can set the desired iconText for your QAction using QAction::setIconText() (i.e. f_action->setIconText("Click..."); right after your f_action->setText call).

Adding attribute to TinyMCE node with attr not working

I'm developing a WordPress plugin that adds a button to TinyMCE, which lets you add an id attribute to the selected element. I have the button displaying, and when it is clicked it runs my function, which I'll call "idFunc" for this demo and it looks like this:
function idFunc() {
// Make sure editor has focus.
editor.focus();
// Get currently selected node
var selectednode = editor.selection.getNode();
// Set the id attribute on the node
selectednode.attr("id","newid");
}
With idFunc() written as above, nothing happens when I click my button. If I change the last line to an alert like this:
function idFunc() {
editor.focus();
var selectednode = editor.selection.getNode();
// Alert with the selected node
alert(selectednode);
}
I get an alert as expected, which says:
The page at mytestingdomain.com says: [object HTMLParagraphElement]
If I have my caret in a div instead of a p element, it says:
The page at mytestingdomain.com says: [object HTMLDivElement]
So I know I'm close, but the attr() function isn't adding any attributes to any elements in the TinyMCE editor.
What am I doing wrong?
The solution to this is easy.
editor.selection.getNode() gives you the common ancestor node (not a jQuery object).
To set the id attribute on the node you may call one of the following commands:
selectednode.setAttribute("id","newid");
or
selectednode.id = "newid";
or using jQuery
$(selectednode).attr("id","newid");

Silverstripe 3.1 Change the default button text of the Gridfield Add button?

How do I change the default button text of the Gridfield Add button?
I guess it's something to do with ->getConfig() , any ideas?
Change the default button text of the Gridfield Add button by one of the following examples:
//$gridfield = ..... // define you gridfield as normal first...then
$gridfield->getConfig()->getComponentByType('GridFieldAddNewButton')->setButtonName('Add Extra Product Gallery Images');
OR add this to your dataobject:
static $singular_name = "Add Extra Product Gallery Image";
static $plural_name = "Add Extra Product Gallery Images";

How to remove an inherited field from a new content type

I'm working with ArgoUML/AGX/Plone 4.1 to generate a subclass using "atevent" as the stereotype. How do I remove the inherited "Event body text" field?
you can set the widget invisible for editing and for viewing.
YourSchema['FieldName'].widget.visible = {'view': 'hidden', 'edit':'hidden' }
If the field is required in the original schema, you'll also need
YourSchema['FieldName'].required = False

How to retrieve the pre edited value of the cell of a datagrid to an itemeditor in a flex

I wrote a custom item editor for a datagrid in flex. My question is how to retrieve the pre-edited value of the datagrid cell after the item editor initializes and also in the custom item editors code.
I don't think it is possible to get the old value once you are in the item editor. I would do this manually by listening to the "itemEditBeginning" event and keeping a variable with the value of the cell. You can then reference that value through the "parent", "parentDocument" or "outerDocument" properties in the item editor, depending on whether you are using an inline item editor or a separate class.
In the "itemEditEnd" event you can access the old value as:
var oldValue:String = event.currentTarget.dataProvider[event.rowIndex].VALUE_FIELD;
and the new value as:
var txtControl:mx.controls.TextInput = event.currentTarget.itemEditorInstance as mx.controls.TextInput;
var newValue:String = txtControl.text;
If you are using a custom itemRenderer you need to change "mx.controls.TextInput" for your custom itemRenderer.

Resources