2013-12-22 16 views
0

我有一個jqGrid的,我想通過一個函數的返回值 設置列的知名度這是我曾嘗試集可視性

colModel: [{ name: 'TypeId', index: 'TypeId', label: 'Type Id', sortable: true, hidden:$.mns.getcolvisiblity() }, 
      {..rest of cols} 


$.mns= 
{ 
    getcolvisiblity:function() 
    { 
    if(mycondition) 
    { 
     return true; 
    } 
    else 
    { 
    return false; 
     } 

我已經把一個斷點,測試,我相信它是基於條件返回true或false,但我的列將永遠隱藏

+0

我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

+0

@JohnSaunders:謝謝,所以現在我確信不會犯下什麼錯誤:) –

回答

0

colModel:[{name:'TypeId',index:'TypeId',label:'Type Id',sortable :true,hidden:false},//默認爲隱藏false {..rest of cols}

$.mns= 
    { 
    getcolvisiblity:function() 
    { 
    if(mycondition) 
    { 
     $("#gridname").hideCol("colname") 
    } 
    else 
    { 
     //do nothing as column is already visible 
    } 
    } 
}, 

並在文檔中準備調用這個函數。

+0

我想出了這個解決方案。如果有其他簡單的方法來完成這個,那麼歡迎您的回答! –