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
  • Hi Syed

    As per my understand, you need two things:
    1. Parent Module Record ID and
    2. Subpanel List Record ID
    to do so:
    custom/modules/<subpanel-module-name>/clients/base/views/subpanel-list/subpanel-list.js
    if you dont have file in this respective path, you can copy it from
    modules/<subpanel-module-name>/clients/base/views/subpanel-list/subpanel-list.js
    or
    clients/base/views/subpanel-list/subpanel-list.js

    then on your click event call a function and in that function add following code

    var parentId = this.context.parent.get('model').get("id"); // It will get parent record id
    var subRecordId = this.model.id; // this will give you current record id from your subpanel

    Hope this Helps!!

    Best Regards
    S Ramana Raju

  • Hi Ramana Raju Santhana

    It worked perfect..!!

    Thanks Ramana Santhana. You saved my time.

    Regards

    Syed

  • Hi Ramana Raju Santhana,

    I am trying the same code.Parent module is Cases and Child module is Documents. I am able to get the parent module id using below code

    var parent_id=this.context.parent.get('model').get('id');

    but I am not able to fetch child record id using the code var document_id=this.model.id; it gives undefined as the result.

    Any idea/suggestion will be really helpful.

    Thanks,

    Sravani.Tedla.

  • 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

Reply
  • 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

Children