2011-07-07 126 views
-4
<script type="text/javascript"> 

//Code added by Nitesh for RFE 670082 starts here 
    jQuery("input[name='hideLineItemColumns_quote']").click(function() { 
     alert(jQuery(this).attr('checked')); 
    if(jQuery(this).attr('checked')){ 
      var columnName = $.trim($(this).val()).replace('\u00a0',''); 

     $('thead.line-item-grid-header tr th').filter(function() 
      { 
       if($.trim($('div', this).text()).replace(' ','') == columnName){ 
        indexValue = $(this).index(); 
        //Hiding body columns 
        jQuery('.line-item-grid-body').children('tr').each(function(){ 
         jQuery(this).children('td:eq('+indexValue+')').hide(); 
        }); 
        //Hiding footer columns 
        jQuery('.line-item-grid-footer').children('tr').each(function(){ 
         jQuery(this).children('th:eq('+indexValue+')').hide(); 
        }); 
        return true; 
      }; 
     }).hide(); 
    } 
    else{ 
      var columnName = $.trim($(this).text()).replace('\u00a0',''); 

     $('thead.line-item-grid-header tr th').filter(function() 
      { 
       if($.trim($('div', this).text()).replace(' ','') == columnName){ 
        indexValue = $(this).index(); 
        //Showing body columns 
        jQuery('.line-item-grid-body').children('tr').each(function(){ 
         jQuery(this).children('td:eq('+indexValue+')').show(); 
        }); 
        //Showing footer columns 
        jQuery('.line-item-grid-footer').children('tr').each(function(){ 
         jQuery(this).children('th:eq('+indexValue+')').show(); 
        }); 
        return true; 
      }; 
     }).show(); 
    } 
}); 
+2

您需要去掉這98%左右,僅發佈應用代碼。沒有人會通讀所有這些。 –

+1

是的,發佈這麼多基本問題的代碼表明,你甚至沒有試圖縮小代碼中的問題所在。 –

+0

對不起,我..我不小心複製了我所有的代碼 – Nitesh

回答

3

變化

if(jQuery(this).attr('checked')){ 

if(jQuery(this).is(':checked')){ 
+0

嘗試...沒有運氣!! ...一旦代碼隱藏列,它永遠不會顯示它回來..我可以看到它正在運行語句包含在else語句但看起來像.show()什麼也沒做 – Nitesh

+0

你試過用螢火蟲調試嗎? – Chandu

+0

是的...沒有什麼...我沒有看到任何錯誤被拋出 – Nitesh