hello, i found the next problem, which you can see in my sample project
On screen “CartEdit” we put goods into “Cart”, where the list of added goods we can see in the table
And I would like to how can I open good’s editor from this table with mouse double click?
I will very grateful for your fast answer!
Regards, Oleg
test.zip (94.2 KB)
durygin
(Gleb Durygin)
March 23, 2020, 6:44am
#3
Hello @olegmps2014 ,
The Table
responds to double click by trying to find and execute the following actions:
itemClickAction
set using the Table#settemClickAction
method;
action, assigned to Enter key press by setting its shortcut
property;
action named “edit” ;
action named “view” .
If one of these actions is found and it is enabled, it is executed.
Your table of goods does not contain any of the above actions. You should add edit
action and a button for this action to the Table:
<table id="goodsTable" dataContainer="goodsDc" width="100%" height="200px">
<actions>
<action id="add" type="add"/>
<action id="edit" type="edit"/>
<action id="exclude" type="exclude"/>
</actions>
<columns>
<column id="name"/>
<column id="cipher"/>
</columns>
<buttonsPanel>
<button action="goodsTable.add"/>
<button action="goodsTable.edit"/>
<button action="goodsTable.exclude"/>
</buttonsPanel>
</table>
Regards,
Gleb
@durygin thank you for your reply, but I have one more question:
How can I do the openned entry only for reading - user could not edit openned entry?
durygin
(Gleb Durygin)
March 23, 2020, 8:08am
#6
@olegmps2014 , in this case, you should use the view action.
Regards,
Gleb
@durygin But there is no such action in the list
durygin
(Gleb Durygin)
March 23, 2020, 8:57am
#8
@olegmps2014 , I am sorry, you are right, the ViewAction was added only from 7.2 platform version.
For the 7.1 version of the platform you need to make your implementation of the ViewAction :
XML descriptor
<table id="goodsTable" dataContainer="goodsDc" width="100%" height="200px">
<actions>
<action id="add" type="add"/>
<action id="exclude" type="exclude"/>
<action id="view" trackSelection="true"/>
</actions>
<columns>
<column id="name"/>
<column id="cipher"/>
</columns>
<buttonsPanel>
<button action="goodsTable.add"/>
<button action="goodsTable.exclude"/>
<button action="goodsTable.view" caption="View" icon="font-icon:EYE"/>
</buttonsPanel>
</table>
Screen controller
@UiController("decoder_Cart.edit")
@UiDescriptor("cart-edit.xml")
@EditedEntityContainer("cartDc")
@LoadDataBeforeShow
public class CartEdit extends StandardEditor<Cart> {
@Inject
private Table<Goods> goodsTable;
@Inject
private ScreenBuilders screenBuilders;
@Subscribe("goodsTable.view")
public void onGoodsTableView(Action.ActionPerformedEvent event) {
Goods editedGoods = goodsTable.getSingleSelected();
if (editedGoods != null) {
Screen goodsEditor = screenBuilders.editor(goodsTable)
.editEntity(editedGoods)
.withScreenClass(GoodsEdit.class)
.build();
ComponentsHelper.walkComponents(goodsEditor.getWindow(), (component, name) -> {
if (component instanceof Component.Editable) {
((Component.Editable) component).setEditable(false);
}
if (component instanceof ActionsHolder) {
((ActionsHolder) component).getActions()
.forEach(action -> action.setEnabled(false));
}
});
goodsEditor.show();
}
}
}
Regards,
Gleb
1 Like
@durygin thank you for advice, I suppose I’ll update to platform 7.2 and already add ViewAction