繁体   English   中英

数据表:如何获取具有特定单元格值的行?

[英]Datatables: How do I get the row with certain cell value?

下面是我创建的表:

var table= $("#mytable").DataTable({

    ajax: "list.json",
    columns: [
        {"data": "name"},
        {"data": "location"},
        {"data": "date"}
    ]
});

现在,我想编辑name为“ John”的行中的location 我尝试过这种方式:

table.search("John").column(0).row(0).cell(1).data(" New location ");

但这由于我不知道的原因而行不通。 任何帮助,将不胜感激。

您可以这样尝试:

foreach(DataRow dr in table.Rows) // Search whole table
{
    if(dr["name"] == "John") // If name== 'John'
    {
        dr["location"] = "New location"; //Change the location
        //break;
    }
    else if()
    {
      // Do Something else
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM