2014-01-29 44 views
-1

目標是使用單元格值在jQuery Datatable中選擇一行。 也許像document.getelementbyvalue 或與jQuery的功能。如何使用單元格值選擇數據錶行?

作爲一個例子,我想在列id中搜索searchvalue的內容,並選擇包含變量searchvalue內容的行。

datatable是一個由mdata填充的jQuery數據表。

下面是代碼:

var searchvalue = null; 

function() 
    {  
    var processURL="path"; 
    $.ajax(
     { 
     type  : "GET", 
     url   : processURL, 
     cache  : false, 
     dataType : "json", 
     success  : function (d) 
      {   
      var oTable = $('#Test').dataTable(); 
      oTable.fnDestroy(); 
      $('#Test').dataTable(
         { 
         "sScrollY": "200px", 
         "bPaginate": false, 
         "sDom": "frtiS", 
         "bDeferRender": true, 
         "aaSorting": [[ 1, "asc" ]], 
         "aaData": d, 
         "aoColumns":  
          [ 
          { "mData": "N1" }, 
          { "mData": "N2" }, 
          { "mData": "3" }, 
          { "mData": "STR" }, 
          { "mData": "PLZ" }, 
          { "mData": "ORT" }, 
          { "mData": "ID" }                
          ], 
         "aoColumnDefs": 
          [ 
           { 
           "sClass": "hide_me", "aTargets": [ 6 ] 
           } 
          ] 
         });    
      var oTable1 = $('#Test').dataTable(); 
      oTable1.fnStandingRedraw();    
      }, 
     error : function (d) 
      {      
      alert('Error'); 
      } 
     }); 
    } 
+1

哪裏是代碼。 –

+0

請詳細說明問題 –

+0

對不起,我添加了代碼。 –

回答

2

這應該工作:

$("td:contains(text)"); 
+0

謝謝,它有一個變量適用於我;-) –

+0

這裏是代碼:var x =「Telefon」; (「tr:contains('」+ x +「')」)。css(「background-color」,「red」); –

0

搜索使用find()表格單元格的字符串:如果它發現它,然後將該類添加到父。

$("table tr td").find("something").parent().addClass('parentCell'); 
相關問題