New UI - Link Lookup/Main Lookup and disabling Field - Forum - Rollbase - Progress Community

New UI - Link Lookup/Main Lookup and disabling Field

 Forum

New UI - Link Lookup/Main Lookup and disabling Field

This question is answered

Hello,

I have a dropdown List (lets call it field B) that is a link lookup on another field (let's call it A) in a QC page.

When A is empty I want to disable B. I am simply doing :

if (rbf_isEmpty(A)){

$('fieldBIntegrationName').data('kendoDropDownList').enable(false);

}

This is not working.

When I remove the link lookup/main lookup, it works fine and the field B is disabled when A is empty. (but I need the link lookup main lookup).

Why is the Link Lookup/ Main Lookup preventing the field from being disabled ? If this is an issue, I would have to filter  the field B manually when A is there, which I would prefer to avoid to reduce coding ...

Any ideas ?

Thank you

Meryem

Verified Answer
  • Hi guys,

    Got this sorted by calling the function on change of the field as an event, instead of doing bind('change', function).

    Thanks

    Meryem

  • Ok I understand makes sense.

    I changed the kendo disabling now to rbf_setFieldDisabled as you are suggesting and it is all fine.

    Thanks :)

    Meryem

All Replies
  • Meryem not able to reproduce this issue at my end.

    Can you please try the following statement:

    rbf_isEmpty(rbf_getFieldValue('R61322')) ? rbf_setFieldDisabled('R61331',true) : rbf_setFieldDisabled('R61331',false);

    Regards,
    Siraj.
  • Hi MeryK,

    I am assuming you are trying to disable it because even though no value is selected in main lookup, the link lookup selector is allowing values to be selected right ? This is a bug till 4.0.3. This has been fixed in 4.0.4.

    For example,  

    I have a customer and contact fields set up as main and link lookup. And i have cust1, cust2 and cust3 records attached to cont1, cont2 and cont3 records respectively. In this case, when no value is given for customer, the contact object does not show up any records for selection. (image below). 

    However, if i select cust1 value for customer field, the same selecotor page shows cont1 record for selection. 

    Are you trying to achieve the same ? If yes, then this is availbale for you in 4.0.4 out-of-box. :)

    Regards,

    Harsha.

  • Siraj, what you are suggesting is not working :(

    Firstly, rbf_isEmpty(rbf_getFieldValue('R61322')) is always true whether the field is empty or not. And secondly rbf_setFieldDisabled('R...', true) is not disabling.

    Sorry I forgot to mention that  both fields A and B are lookup fields, maybe this is why you are unable to reproduce ..

    Harsha, you are saying that : "I am assuming you are trying to disable it because even though no value is selected in main lookup, the link lookup selector is allowing values to be selected right ? This is a bug till 4.0.3. This has been fixed in 4.0.4.".

    Well not really. I need to disable the link lookup field because I simply have an order to be respected while filling up the fields. So I need to make sure that field B is enabled only once field A is filled in.

    What you are explaining is something else. But good to know thanks :)

    Any more suggestions ?

    Thanks guys.

    Meryem

  • Ok. No issues. You can try the following snippet to disbale/enable the look up controls.

    (assuming Rxyzab' is the integration name of the dependent lookup field. )

    You can get hold of the controls like below...

    // textbox of the lookup control.

    var lookup_textBox = $("select[name=Rxyzab]").data('kendoMultiSelect');

    // search btn of the lookup control

    var lookup_searchBtn = $($("#rbi_F_Rxyzab").find(".k-button")[0]).data('kendoButton');

    // plus btn of the loopkup control.

    var lookup_addBtn = $($("#rbi_F_Rxyzab").find(".k-button")[1]).data('kendoButton');

    Now you can use

    lookup_textBox.enable(false);

    lookup_searchBtn.enable(false);

    lookup_addBtn.enable(false);

    to disable them.  

    And upon requirement you can re-enable them by

    lookup_textBox.enable();

    lookup_searchBtn.enable();

    lookup_addBtn.enable();

    So, by adding disabling login on page load and re-enabling logic on foucs/change event of the main-lookup, you should be able to achive what you are looking for.

    Hope this helps. Please let us know if you need anything else.

    Regards,

    Harsha.

  • Hi Harsha,

    Ok I think I did not mention that the lookup field I am talking about is a picklist. So I dont have any search Button or add Button to disable.

    I will resume the situation again:

    On a QC page I have a lookup field A, rendered as a Selector. Then I have a lookup field B rendered as a Picklist.

    A is a main lookup and B is a link lookup on A in that object.

    Here is what I am doing :

    
    
    function enableDisableFieldB(){
    
    var fieldAmultiSelect = $('#fieldA').data('kendoMultiSelect');  
    
    if(rbf_isEmpty(fieldAmultiSelect.value()){
    
        $('#fieldB').data('kendoDropDownList').enable(false);
    
    }
    
    else{
    
     $('#fieldB').data('kendoDropDownList').enable(false);
    
    }
    
    }
    
    $(document).ready(function(){
    
    enableDisableFieldB(); // This one is working
    
    fieldAMultiSelect.bind('change', function(){
    
     enableDisableFieldB(); // This one is not
    
    })
    
    });

    Do you see the problem now ? When I remove the main lookup/link lookup between A and B it is working fine.

    Thanks
    Meryem




  • Hi guys,

    Got this sorted by calling the function on change of the field as an event, instead of doing bind('change', function).

    Thanks

    Meryem

  • Meryem, great that you got it working.

    However, would like to share with you that for enabling/disabling fields, instead of directly working with kendo widgets, you should ideally be calling:

    rbf_setFieldDisabled(fieldName, isDisabled).

    That is you should leverage Rollbase Client-side API where all possible. Only in scenarios, where in API functionality is limited should we work directly with DOM elements.

    This way, you can be reset assured that there will not be any compatibility issues going forward.

    Regards,
    Siraj.
  • Ok I understand makes sense.

    I changed the kendo disabling now to rbf_setFieldDisabled as you are suggesting and it is all fine.

    Thanks :)

    Meryem