2014-10-29 96 views
0

我有一個jqQrid,我已經放置在HTML表格中。現在根據我的要求,我必須在超鏈接點擊打開的動態選項卡中顯示此網格。如何在動態選項卡中添加內容

這裏是一個動態的標籤創建代碼:

function addTab(title) { 
    if ($('#tt').tabs('exists', title)) { 
     $('#tt').tabs('select', title); 
    } 
    else { 
     if (title == "Check in List") { 
      //Here i have to call jqgrid loading function but how I am not getting !!! 
      var content = ''; 
     } 
     else { 
      var content = '<p>Hii</p>'; 
     } 
     $('#tt').tabs('add', { 
      title: title, 
      content: content, 
      closable: true 
     }); 
    } 
} 

這裏是生成網格功能:

function CheckInRecordgrid() { 
    //Grid Codes 
} 

這裏是HTML表格佔位符:

<table id="CheckIngrid"></table> 

現在我的問題是如果點擊標籤是根據條件如何調用網格生成函數?

這裏是我的滿格代碼..

 function CheckInRecordgrid() { 
     var data = [[48803, "DELUX", "A", "2014-09-12 12:30:00", "Done"], [48804, "NORAML", "V", "2014-09-12 14:30:00", "Pending"]]; 

     $("#CheckIngrid").jqGrid({ 
      datatype: "local", 
      height: '100%', 
      autowidth: true, 
      colNames: ['Room No.', 'Category', ' Guest name', ' Date & Time ', 'Status'], 
      colModel: [ 
        { 
         name: 'Room No.', index: 'Room No.', width: 100, align: 'center' 
        }, 
        { 
         name: 'Category', index: 'Category', width: 100, align: 'center' 
        }, 
        { 
         name: 'Guest name', index: 'Guest name', width: 100, align: 'center' 
        }, 
        { 
         name: 'Date & Time', index: 'Date & Time', width: 100, align: 'center' 
        }, 
        { 
         name: 'status', index: 'status', width: 100, align: 'center' 
        } 
       ], 
      caption: "Check In List" 
     }); 

     var names = ["Room No.", "Category", "Guest name", "Date & Time", "status"]; 
     var mydata = []; 

     for (var i = 0; i < data.length; i++) { 
      mydata[i] = {}; 
      for (var j = 0; j < data[i].length; j++) { 
       mydata[i][names[j]] = data[i][j]; 
      } 
     } 

     for (var i = 0; i <= mydata.length; i++) { 
      $("#CheckIngrid").jqGrid('addRowData', i + 1, mydata[i]); 
     } 
    } 
+0

調用if條件裏面的函數,它應該是'如果(標題== 「檢查表」){ CheckInRecordgrid(); '';}' – bipen 2014-10-29 07:54:21

+0

@bipen我試過了但現在網格沒有顯示出來..它只是空白.. – 2014-10-29 07:56:33

+0

@bipen先生,我已經更新了我的帖子,全網格代碼也..請看看。 。謝謝 – 2014-10-29 07:59:41

回答

0

試試這個

if (title == "Check in List") { 
    var content = ''; 
    }else { 
    var content = '<p>Hii</p>'; 
    }; 

    $('#tt').tabs('add', { 
     title: title, 
     content: content, 
     closable: true, 
    }).tabs({ 
     onAdd: function(title,index){ 
      if (title == "Check in List") { 
      CheckInRecordgrid(); 
      } 
     } 
    });