CMDBuild Forum

How to set auto-focus on a specific attribute when editing a card?

Dear all, I’m looking for a CMDBuild configuration that let me to set an auto-focus on a card attribute, so end-users, when edit a card, can start to digit a new value in the attribute itself with no need to point and click with the mouse, and then can move on other attributes using Tab button. I’ve searched over CMDBuild card configuration, but I haven’t find anything about it. Would it be possible?
Thanks in advance.
Daniele

1 Like

Quick, but a bit dirty hack - put this into Auto Value:

if ('CMDBuildManagementDetailsWindow' === Ext.get(Ext.Element.getActiveElement()).id) {
Ext.ComponentQuery.query('[name=ParentCode]')[0].focus('', 200);
}

1 Like

Thank you very much, @pmg ! I did a little modification, in order to support both card creation and card edit. Below my solution (in case it would be helpful for others):

if ('CMDBuildManagementDetailsWindow' === Ext.get(Ext.Element.getActiveElement()).id) {
    if (Ext.ComponentQuery.query('[name=Description]').length == 2) {
        Ext.ComponentQuery.query('[name=Description]')[1].focus('', 200);
    } else {
        Ext.ComponentQuery.query('[name=Description]')[0].focus('', 200);
    }
}
1 Like