[4.0.4.0] - Disable the New Button - Related List

Posted by IramK on 08-Jun-2016 11:12

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

Posted by Rajkumar Mateti on 08-Jun-2016 11:43

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  

Posted by IramK on 08-Jun-2016 11:50

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

Posted by Vimalkumar Selvaraj on 09-Jun-2016 12:52

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.

Posted by IramK on 22-Jun-2016 08:40

Hello Vimal,

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

Cheers.

Iram

This thread is closed