Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
replacing tri state checkbox image URLs
posted

I am trying to override the default image URLs without overwriting my theme's image files (as this will cause issues when upgrading the toolset). I have new images in a different folder and would like to assign them to _checkedImageURL, _uncheckedImageURL and _partialImageURL by default. Is there a way to do this?

Barring that I have created an init function which overrides the images on initialize. The problem with this code is that when a checkbox is in the unchecked state, the line var oTmpNode = oNodeList._items[nodeCounter]; returns undefined which means all checkboxes get reset properly except the unchecked ones. Code follows:

function setCheckboxImage(oNodeList, oTree) {
  if (oNodeList._items) {
    for (var nodeCounter = 0; nodeCounter < oNodeList._items.length; nodeCounter++) {
      var oTmpNode = oNodeList._items[nodeCounter];

      switch (oTmpNode.get_checkState()) {
        case 1:
          oTmpNode._get_checkBoxElement().src = oTree.Tree._checkedImageURL;
          break;
        case 2:
          oTmpNode._get_checkBoxElement().src = oTree.Tree._partialImageURL;
          break;
        default:
          oTmpNode._get_checkBoxElement().src = oTree.Tree._uncheckedImageURL;
          break;

    }

    if (oTmpNode._itemCollection) {
      setCheckboxImage(oTmpNode._itemCollection, oTree);
    }

  }

}
return true;
}

function wtFeatures_Initialize(sender, args) {

var oTree = igtree_getTreeById(m_wtFeaturesId);
oTree.Tree._checkedImageURL = "../css/ig_res/override/images/ig_checkbox_on.gif";
oTree.Tree._uncheckedImageURL = "../css/ig_res/override/images/ig_checkbox_off.gif";
oTree.Tree._partialImageURL = "../css/ig_res/override/images/ig_checkbox_partial.gif";

var oNodes = oTree.getNodes();
setCheckboxImage(oNodes,oTree);

}

Is there a bug here or am I missing something?

  • 10685
    Offline posted

    Hello,

    Thank you for posting in our community!

    I have played a bit with the code you have shared with us, and it appears the oNodes passed to the setCheckBoxImage method is containing only the first node. This is why the method fails when trying to increment by one and change the next node image as well. During my test I came with a runnable code sample, so I am attaching a slightly modified version of the code. I am attaching it to my reply for reference and in order to illustrate a solution/workaround and to point to the real issue. The point here is to obtain the next node to iterate from the setCheckBoxImage method like
    var oTmpNode = oTree.getNode(nodeCounter);
     

    Please let me know how this approach works for you!

    WDT_ChangeImg.zip