Interactive Grid Column header Click option Disable Fixt

 

Interactive Grid Column header Click option Disable Fixt.
এই কাজটা তিনটা সিস্টেমে করা যায়।
               ১) এক কোডে কিছু Disable, কিছু Enable করা।
               ২) এক কোডে সব 
Click Disable করা।
               ৩) একটা একটা কলাম ধরে ধরে Click Disable করা।

============================================

 ১) এক কোডে কিছু Disable, কিছু Enable করা।

Go to Grid Region Attributes --> Initialization JavaScript Function:

function(config) {

  var regionId = "master_ig";  // Grid Static ID: master_ig

  // সব নাম Uppercase করো (কারণ নিচে headerText.toUpperCase() ব্যবহার হয়েছে)

  // Console থেকে পাওয়া নামগুলো এখানে দাও 

  // Go to console log--> $("#master_ig .a-GV-headerLabel").map((i,e)=>$(e).text().trim()).get();

  // মূলত Column এর Hading এর নাম গুলো  যেভাবেই দেওয়া থাকুন না কেন, এখানে Upper case করে দিতে হবে।

  var allowedHeaders = ["MA ORDER ID", "CUST. CODE", "CUSTOMER NAME"]; 


  function disableHeaders() {

    var headers = $("#" + regionId + " .a-GV-headerLabel, #" + regionId + " th");


    if (headers.length > 0) {

      console.log("✅ Found", headers.length, "headers. Processing...");


      headers.each(function() {

        var $h = $(this);

        var headerText = $h.text().trim().toUpperCase();


        if (allowedHeaders.includes(headerText)) {

          // ✅ এইগুলো enable থাকবে, এবং "blue" কালার দিবে

          $h.css({

            "pointer-events": "auto",

            "color": "blue",

            "cursor": "pointer"

          });

        } else {

          // ❌ বাকিগুলো disable, এবং "gray" কালার দিবে

          $h.css({

            "pointer-events": "none",

            "color": "gray",

            "cursor": "not-allowed"

          });

        }

      });

    } else {

      console.log("⏳ Headers not ready yet, retrying...");

      setTimeout(disableHeaders, 500);

    }

  }


  // একটু delay দিয়ে run করাই ভালো (grid load হয় ধীরে)

  setTimeout(disableHeaders, 1200);

  return config;

}


২) এক কোডে সব Disable করা।

Go to Grid Region Attributes --> Initialization JavaScript Function:


function(config) {

    var cfg = config;

    cfg.afterRefresh = function() {

        disableGridHeaders();

    };


    function disableGridHeaders() {

        try {

          var ig$ = apex.region("master_ig").widget(); // Grid Static ID: master_ig

            var grid = ig$.interactiveGrid("getViews", "grid");

            if (grid && grid.view$) {

                // Disable all header interactions

                grid.view$.find(".a-GV-header").each(function() {

                    $(this)

                        .off() // remove all existing events

                        .css({

                            "pointer-events": "none",

                            "cursor": "default",

                            "background-color": "#fafafa"

                        })

                        .attr("title", ""); // remove tooltip

                });

            }

        } catch (e) {

            console.error("Header disable error:", e);

        }

    }


    // Also disable on first load

    setTimeout(disableGridHeaders, 600);


    return cfg;

}


৩) একটা একটা কলাম ধরে ধরে Click Disable করা।

Select Column --> Column Initialization JavaScript Function:

function(config) {

    config.defaultGridColumnOptions = {
        noHeaderActivate:  true
    };  
    return config;
}


Post a Comment

Previous Post Next Post