[4.0.4.0] - Disable the New Button - Related List - Forum - Rollbase - Progress Community

[4.0.4.0] - Disable the New Button - Related List

 Forum

[4.0.4.0] - Disable the New Button - Related List

This question is not answered

Hello,

I have the main record page and there is a related list of records available for that record. I would like to disable the "New" button for that related list. I have tried many techniques but none of them seem to remove the click functionality of that new button. What is the best way to achieve this?

Cheers.

Iram

All Replies
  • Hi,

    Click on Design This Page of record page

    Click on Related List Property panel Icon

    Uncheck the "Show New Link" and "Enable Quick Create" check boxes and Save.

    Hope This helps.

    Thanks,

    Rajkumar  

  • Sorry Rajkumar,

    I think I did not explain it properly. I would like to disable it programmatically based on a condition. I am aware of that option on the design of the page. Could you please get back to me with a programmatical way of disabling the new button?

    Cheers.

    Iram

  • Hi ,

    You can't prevent New record create button click action even you add "k-state-disabled"  (Usually "k-state-disabled" class will be added to button by Kendo if it is disabled)  class through program, because we always hide this button from user if they don't have permission ( we don't disable them) where as some other buttons like "delete or more actions" disabled when no record is selected, so we always prevent click actions if those buttons have "k-state-disabled" css class . I would suggest you to hide New record create button from toolbar based on your condition. I wrote a code snippet to hide/show them conditionally.

    <script>

    //Listen for page render, tab activate and session expanded events,you can remove if you have only one tab.

    //Added all events just to make sure don't miss any scenario

    $(document).on(rb.newui.util.customEvents.rbs_pageRender +" "+rb.newui.util.customEvents.rbs_tabActivated+" "+rb.newui.util.customEvents.rbs_sectionExpanded,function(){

      hideCreateRecordButton(true);

    });

    function hideCreateRecordButton(condition){

      var pageComponent = rb.newui.page.PageContext.getPageComponent(179622); //CellId of your related list

      if(pageComponent){

     var kendoConfig = pageComponent.getKendoConfig();

     if(kendoConfig){

       var gridEle = pageComponent.getKendoConfig().element; //Get grid element

    var gridToolbarContainer =  gridEle.prev('.gridToolbarContainer'); //Get grid toolbar element

    var newBtnEle = gridToolbarContainer .find('.gridToolbar .rbs-gridNewObjCreateBtn'); //Get new record button element

    if(condition===true){

      newBtnEle.hide();

    }else{

      newBtnEle.show();

    }

     }

      }

    }

    </script>

    Hope this helps,

    Vimal.

  • Hello Vimal,

    Thanks for your reply. Could you suggest me a programmatic way of retrieving the cellId of my related list please?

    Cheers.

    Iram