且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento 选择字段禁用相关产品中的行

更新时间:2023-11-30 13:16:40

行点击事件使用了一个名为'openGridRow'的函数

The row click event uses a function called 'openGridRow'

在您的网格中包含一些 javascript,并使用一些自定义代码添加此函数以在满足某些条件时取消事件.然后将复选框设置回选中状态.

Include some javascript with your grid, and add this function with some custom code to cancel the event if certain conditions are met. Also then set the checkbox back to checked.

示例将是

function openGridRow(grid, event){
                var element = Event.findElement(event, 'tr');
                //alert(Event.element(event).tagName.toLowerCase());
                if(Event.element(event).type != 'checkbox'){
                  if(['img', 'a', 'input', 'select', 'option', 'img'].indexOf(Event.element(event).tagName.toLowerCase())!=-1) {
                      // re-enable the checkbox
                      var checkbox = Element.select(element, 'input');
                      if(checkbox[0] && !checkbox[0].disabled){
                          grid.setCheckboxChecked(checkbox[0], true);
                      }
                      return;
                  }
                }
                if(element.title){
                    setLocation(element.title);
                }
    }    

上面的例子什么都不做,如果点击的元素类型是a, input, select or option其他一切都将照常进行.

The above example will do nothing, if the element type clicked is a, input, select or option Anything else will continue as per normal.