- Back to Home »
- custom shortcut keys , sugarcrm »
- Creating custom keyboard shortcuts in sugarcrm
Posted by : Ajay Kumar
Thursday, 14 January 2016
Let me say something about shortcut keyboard in sugarcrm,How it can be done.
Here is sample, Open any record in any module.And press "e".
Now you will be able to see the edit view of that record. like the same
To Save a record ,press "ctrl+s" or "ctrl+alt+a"
To Edit a record press "e" or "ctrl+alt+i"
To Cancel a edit view press "esc" or "ctrl+alt+l"
To Go to next record press "l"
To Go to previous record press "h"
To Get more action button press "m"
These all are default sugar shortcut keys.yes .Its interesting.Then why cant we try creating/registering our shortcut key.
Let we try to create our custom shortcut key.
Steps:
Step 1:
Create file record.js in below path
custom/modules/{module-name}/clients/base/layouts/record/record.js
custom/modules/Accounts/clients/base/layouts/record/record.js
Then copy content from
custom/modules/Accounts/clients/base/layouts/record/record.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*custom/modules/Accounts/clients/base/layouts/record/record.js | |
* Ajay Kumar | |
*/ | |
({ | |
plugins: ['ShortcutSession'], | |
shortcuts: ['Sidebar:Toggle', 'Record:Edit', 'Record:Delete', 'Record:Save', 'Record:Cancel', 'Record:Previous', 'Record:Next', 'Record:Favorite', 'Record:Follow', 'Record:Copy', 'Record:Action:More', 'Record:Test'] | |
}) |
Step 2:
custom/modules/Accounts/clients/base/views/record/record.js
In this file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/*Registering Button action for Keyboard shortcut | |
* Ajay Kumar | |
* custom/modules/Accounts/clients/base/views/record/reord.js | |
*/ | |
extendsFrom: 'RecordView', | |
initialize: function(options) { | |
this._super('initialize', [options]); | |
this.events = _.extend({}, this.events, { | |
'click a[name=test_button]': '_testAlert', | |
}); | |
}, | |
_testAlert: function() { | |
app.alert.show('Validate', { | |
level: 'info', | |
messages: 'SugarCRM info message', | |
autoClose: false, | |
}); | |
}, | |
registerShortcuts: function() { | |
app.shortcuts.register('Record:Test', ['t', 'ctrl+alt+t'], function() { //here Record:Test | |
this.$('.headerpane [data-toggle=dropdown]:visible').click().blur(); | |
this.$('.headerpane [name=test_button]:visible').click(); //clicking the button | |
}, this); | |
this._super('registerShortcuts'); //calling super function | |
}, | |
}) |
't', 'ctrl+alt+t' - shortcut key
Done.
Post a Comment