How to get parent module record id in subpanel list, also how i will get subpanel list record id when we click on any record

Hi Friends

How to get parent module record id in subpanel list, also how i will get subpanel list record id when we click on any record. Can anyone help me out from this.
Thanks in Advance.

Regards

Syed Sharif Ramana Raju SanthanaTevfik TümerMehul  Bhandari

Parents Reply Children
  • Hi Sravani,

                            You can try ajax requests

    Regards

    Sidhu

  • Sravani Tedla

    Can you share your code and path to the file where you are writing the code.

    So that i can help you further.

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana,

    Thanks for the response.

    I have been writing code in the below path.

    custom/modules/Documents/clients/base/views/subpanel-list/subpanel-list.js

    ({
    extendsFrom:'SubpanelListView',
    initialize:function(options)
    {
    this.plugins=_.union(this.plugins||[],['HistoricalSummary']);
    this._super('initialize',[options]);this.events = _.extend({}, this.events, {
    'click [name=doc_preview]': 'docPreview',
    });
    },

    docPreview:function(){
    var parentId = this.context.parent.get('model').get("id"); // It will get parent record id
    var subRecordId = this.model.id;
    alert(parentId);
    alert(subRecordId);
    },
    })

    My Actual requirement is .. We need to show the preview of the document uploaded in the documents module which is subpanel of the cases module.

    And I am trying to achieve as below.

    For that i have placed a button next to edit/unlink a preview button in the below path

    custom/modules/Documents/clients/base/views/subpanel-list/subpanel-list.php

    <?php
    // created: 2016-04-22 03:34:28
    $viewdefs['Documents']['base']['view']['subpanel-list'] = array (

    'panels' =>
    array (
    0 =>
    array (
    'name' => 'panel_header',
    'header' => true,
    'fields' =>
    array (
    0 =>
    array (
    'name' => 'document_name',
    'label' => 'LBL_LIST_DOCUMENT_NAME',
    'enabled' => true,
    'default' => true,
    'link' => true,
    ),
    1 => array (
    'name' => 'filename',
    'label' => 'LBL_LIST_FILENAME',
    'enabled' => true,
    'default' => true,
    'readonly' => true,
    ),
    2 =>
    array (
    'name' => 'category_id',
    'label' => 'LBL_LIST_CATEGORY',
    'enabled' => true,
    'default' => true,
    ),
    3 =>
    array (
    'name' => 'doc_type',
    'label' => 'LBL_LIST_DOC_TYPE',
    'enabled' => true,
    'default' => true,
    'readonly' => true,
    ),
    4 =>
    array (
    'name' => 'status_id',
    'label' => 'LBL_LIST_STATUS',
    'enabled' => true,
    'default' => true,
    ),
    5 =>
    array (
    'name' => 'active_date',
    'label' => 'LBL_LIST_ACTIVE_DATE',
    'enabled' => true,
    'default' => true,
    ),
    ),
    ),
    ),
    'rowactions' =>
    array (
    'actions' =>
    array (
    0 =>
    array (
    'type' => 'rowaction',
    'name' => 'edit_button',
    'icon' => 'fa-pencil',
    'label' => 'LBL_EDIT_BUTTON',
    'event' => 'list:editrow:fire',
    'acl_action' => 'edit',
    'allow_bwc' => true,
    ),
    1 =>
    array (
    'type' => 'unlink-action',
    'icon' => 'fa-chain-broken',
    'label' => 'LBL_UNLINK_BUTTON',
    ),
    2 =>
    array (
    'type' => 'rowaction',
    'name' => 'doc_preview',
    'label' => 'Preview',
    'allow_bwc' => true,
    ),

    ),

    ),
    );

    And on click of preview when i get the id of the document i will write an ajax request and show in an iframe.

    so on click of preview button i m trying to alert this value var document_id=this.model.id;.. it alerts as undefined.

    But the same code works fine for onchange event.. Like if I try to change the catergory_id and give an alert of document id.. I am able to alert it..

    But it fails for onclick.

    Any idea/suggestion to achieve this requirement in this way/other will be really helpful.

    Thanks and Regards,

    Sravani.Tedla

  • Sravani Tedla

    Try below change of code once:

    Add  following code

    'event' => 'button:doc_preview:click'  

    in custom/modules/Documents/clients/base/views/subpanel-list/subpanel-list.php in

    2 => 
    array (
    'type' => 'rowaction',
    'name' => 'doc_preview',
    'label' => 'Preview',
    'allow_bwc' => true,
    ),

    And also following code:

    Initialize:function(options)
    {
    this.plugins=_.union(this.plugins||[],['HistoricalSummary']);
    this._super('initialize',[options]);this.events = _.extend({}, this.events, {
    this.context.on('button:doc_preview:click',this.docPreview,this);
    });
    },

    in custom/modules/Documents/clients/base/views/subpanel-list/subpanel-list.js and do Quick R&R.

    Hope this Helps

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana,

    Thanks for the help!

    But again same issue  it gives me undefined for 

     var docid= this.model.get("id");

    even i use 

    this.context.on('button:doc_preview:click',this.docPreview,this);

     

    Regards,

    Sravani.Tedla.

  • Sravani Tedla

    Its a working code i have given Sravani.

    Can you share your code.

    Best Regards

    S Ramana Raju

  • hi Ramana Raju Santhana,

    Thanks for the reply,

    i have used below code.

    ({
    extendsFrom:'SubpanelListView',
    initialize:function(options)
    {
    this.plugins=_.union(this.plugins||[],['HistoricalSummary']);
    this._super('initialize',[options]);
    this.events = _.extend({}, this.events, {
    this.context.on('button:doc_preview:click',this.docPreview,this);

    });
    },

    docPreview:function(){
    var parentId = this.context.parent.get('model').get("id"); // It will get parent record id
    var subRecordId = this.model.id;
    console.log(parentId);
    console.log(subRecordId);
    },
    })

    And now one more issue i am facing i have some studio level changes for the subpanel of the documents module for cases. Now new file has been created by name subpanel-for-cases-documents.php in the below path

    custom/modules/Documents/clients/base/views/subpanel-for-cases-documents

    Now the code present in subpanel-list.php (i.e the preview button added ) is not effecting. so for that i have added button  now again in subpanel-for-cases-documents.php.Is this the best procedure?

    Thanks for your time.

    Regards,

    Sravani.Tedla.