Overriding the Preview Button in the List view of a module

In the list view of the Leads module, I want to override the action of the preview button next to each record so that clicking on it opens up the preview pane as well as putting the selected row into edit mode.

Platform: Sugar ondemand version 11.1

I am able to override the preview button as below but how do I trigger the 'Edit' action, as if I had clicked on the 'Edit' from the dropdown list next to the preview button?

// custom/modules/Leads/clients/base/views/recordlist.js
*/
({
  extendsFrom: 'RecordlistView',

  initialize: function(options) {
  this._super("initialize", [options]);

  this.context.on('list:preview:fire', this.preview_clicked, this);

},

preview_clicked: function(model) {

  console.log('Preview button clicked');

  //??? trigger/call the editrow action ???

},

Parents
  • I have not played with customizing the preview pane, but when I want to override some behavior I tend to try and reverse engineer how it is implemented. In this case the first thing I would do is look for the action behind the pencil icon

    If you look at the preview-header

     clients/base/views/preview-header/preview-header.js

    you will see that depending on the layout, they add an event 'click [data-action=edit] which, when clicked, triggers a function triggerEdit which in turn toggles the SaveAndCancel and triggers the preview:edit. 

    There seems to be a lot more behind the layout selection, so just triggering the preview:edit is probably not enough, you will most likely want to also set the layout correctly when you click the preview button on the recordlist.

    It will take some more digging to figure out the details, but this might be a starting point for you.

    Good luck, I'll be interested in seeing what you, and others, come up with.

    FrancescaS

Reply
  • I have not played with customizing the preview pane, but when I want to override some behavior I tend to try and reverse engineer how it is implemented. In this case the first thing I would do is look for the action behind the pencil icon

    If you look at the preview-header

     clients/base/views/preview-header/preview-header.js

    you will see that depending on the layout, they add an event 'click [data-action=edit] which, when clicked, triggers a function triggerEdit which in turn toggles the SaveAndCancel and triggers the preview:edit. 

    There seems to be a lot more behind the layout selection, so just triggering the preview:edit is probably not enough, you will most likely want to also set the layout correctly when you click the preview button on the recordlist.

    It will take some more digging to figure out the details, but this might be a starting point for you.

    Good luck, I'll be interested in seeing what you, and others, come up with.

    FrancescaS

Children
No Data