Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为每行引导数据表的列添加锚定标记_Javascript_Jquery_Twitter Bootstrap_Datatable - Fatal编程技术网

Javascript 如何为每行引导数据表的列添加锚定标记

Javascript 如何为每行引导数据表的列添加锚定标记,javascript,jquery,twitter-bootstrap,datatable,Javascript,Jquery,Twitter Bootstrap,Datatable,我有一个页面,其中一些搜索事件正在刷新数据 数据由Bootstrap Datatablewiajax呈现,它返回json响应 下面是呈现表格的小代码: function renderTable(url, table, query) { $.ajax({url: url, data: query, success: function(data) { $(table).dataTable({ aaData: data.a

我有一个页面,其中一些搜索事件正在刷新数据

数据由
Bootstrap Datatable
wiajax呈现,它返回
json响应

下面是呈现表格的小代码:

function renderTable(url, table, query) {
    $.ajax({url: url,
        data: query,
        success: function(data) {
        $(table).dataTable({
            aaData: data.aaData,
            aoColumns: data.aoColumns,
            bProcessing: true,
            iDisplayLength: 50,
            bDestroy: true
        });
        }
       });
}

我希望所有
Name
列都应该是一个锚定标记,带有指向某个url(show profile)的链接,带有Name参数和值。像-

http://url.com/profile?name=Airi%20satau

这是一个古老的问题,但我在谷歌上偶然发现了它,所以我想我应该在这里发布一个答案,以防其他人碰巧出现在这里

根据您的路由,您可以让jQuery添加一个单击事件,并根据名称进行修改。假设“name”td标记被赋予.name类:

  $(".name").click(function() {
        var suffix = $(this).text().split(' ').join('%20'); //replace the space in the name with %20
        window.document.location = "http://url.com/profile?name=" + $(this).text(); //append to the url string and change document location
  });

这个问题的诀窍是确保它与您的路由一起工作,基于这个示例,它应该是这样的。

这是一个老问题,但我在谷歌上偶然发现了它,所以我想我会在这里发布一个答案,以防有其他人出现

根据您的路由,您可以让jQuery添加一个单击事件,并根据名称进行修改。假设“name”td标记被赋予.name类:

  $(".name").click(function() {
        var suffix = $(this).text().split(' ').join('%20'); //replace the space in the name with %20
        window.document.location = "http://url.com/profile?name=" + $(this).text(); //append to the url string and change document location
  });

这个问题的诀窍是确保它与您的路由一起工作,基于这个示例,它应该是这样的。

这是一个老问题,但我在谷歌上偶然发现了它,所以我想我会在这里发布一个答案,以防有其他人出现

根据您的路由,您可以让jQuery添加一个单击事件,并根据名称进行修改。假设“name”td标记被赋予.name类:

  $(".name").click(function() {
        var suffix = $(this).text().split(' ').join('%20'); //replace the space in the name with %20
        window.document.location = "http://url.com/profile?name=" + $(this).text(); //append to the url string and change document location
  });

这个问题的诀窍是确保它与您的路由一起工作,基于这个示例,它应该是这样的。

这是一个老问题,但我在谷歌上偶然发现了它,所以我想我会在这里发布一个答案,以防有其他人出现

根据您的路由,您可以让jQuery添加一个单击事件,并根据名称进行修改。假设“name”td标记被赋予.name类:

  $(".name").click(function() {
        var suffix = $(this).text().split(' ').join('%20'); //replace the space in the name with %20
        window.document.location = "http://url.com/profile?name=" + $(this).text(); //append to the url string and change document location
  });

这样做的诀窍是确保它与您的路由一起工作,根据示例,它应该工作。

我遇到了相同的场景,我必须在数据表列中显示锚定标记来代替原始文本。下面给出了对我有效的解决方案

$(document).ready(function () {
        $('#example').DataTable({
            "ajax": yourDataURL,
            "columns": [ // Defines column for the output table
                    { "data": "InventoryId" }, // Attribute of item in collection
                    { "data": "InventoryName" },
                    { "data": "InventoryManager" },
                    { "data": "InventoryActive1",
                        "orderable": false,
                        "searchable": false,
                        "render": function(data,type,row,meta) { // render event defines the markup of the cell text 
                            var a = '<a><i class="fa fa-edit"></i>  ' + row.InventoryName +'</a>'; // row object contains the row data
                            return a;
                        }
                    }
            ]
        });
    });
$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:yourDataURL,
“columns”:[//定义输出表的列
{“data”:“InventoryId”},//集合中项的属性
{“数据”:“InventoryName”},
{“数据”:“库存管理器”},
{“数据”:“InventoryActive1”,
“可订购”:错误,
“可搜索”:错误,
“render”:函数(数据、类型、行、元){//render事件定义单元格文本的标记
变量a=''+row.InventoryName+'';//row对象包含行数据
返回a;
}
}
]
});
});

希望这对陷入相同场景的人有所帮助

我陷入了同样的场景,我必须在数据表列中显示锚定标记来代替原始文本。下面给出了对我有效的解决方案

$(document).ready(function () {
        $('#example').DataTable({
            "ajax": yourDataURL,
            "columns": [ // Defines column for the output table
                    { "data": "InventoryId" }, // Attribute of item in collection
                    { "data": "InventoryName" },
                    { "data": "InventoryManager" },
                    { "data": "InventoryActive1",
                        "orderable": false,
                        "searchable": false,
                        "render": function(data,type,row,meta) { // render event defines the markup of the cell text 
                            var a = '<a><i class="fa fa-edit"></i>  ' + row.InventoryName +'</a>'; // row object contains the row data
                            return a;
                        }
                    }
            ]
        });
    });
$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:yourDataURL,
“columns”:[//定义输出表的列
{“data”:“InventoryId”},//集合中项的属性
{“数据”:“InventoryName”},
{“数据”:“库存管理器”},
{“数据”:“InventoryActive1”,
“可订购”:错误,
“可搜索”:错误,
“render”:函数(数据、类型、行、元){//render事件定义单元格文本的标记
变量a=''+row.InventoryName+'';//row对象包含行数据
返回a;
}
}
]
});
});

希望这对陷入相同场景的人有所帮助

我陷入了同样的场景,我必须在数据表列中显示锚定标记来代替原始文本。下面给出了对我有效的解决方案

$(document).ready(function () {
        $('#example').DataTable({
            "ajax": yourDataURL,
            "columns": [ // Defines column for the output table
                    { "data": "InventoryId" }, // Attribute of item in collection
                    { "data": "InventoryName" },
                    { "data": "InventoryManager" },
                    { "data": "InventoryActive1",
                        "orderable": false,
                        "searchable": false,
                        "render": function(data,type,row,meta) { // render event defines the markup of the cell text 
                            var a = '<a><i class="fa fa-edit"></i>  ' + row.InventoryName +'</a>'; // row object contains the row data
                            return a;
                        }
                    }
            ]
        });
    });
$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:yourDataURL,
“columns”:[//定义输出表的列
{“data”:“InventoryId”},//集合中项的属性
{“数据”:“InventoryName”},
{“数据”:“库存管理器”},
{“数据”:“InventoryActive1”,
“可订购”:错误,
“可搜索”:错误,
“render”:函数(数据、类型、行、元){//render事件定义单元格文本的标记
变量a=''+row.InventoryName+'';//row对象包含行数据
返回a;
}
}
]
});
});

希望这对陷入相同场景的人有所帮助

我陷入了同样的场景,我必须在数据表列中显示锚定标记来代替原始文本。下面给出了对我有效的解决方案

$(document).ready(function () {
        $('#example').DataTable({
            "ajax": yourDataURL,
            "columns": [ // Defines column for the output table
                    { "data": "InventoryId" }, // Attribute of item in collection
                    { "data": "InventoryName" },
                    { "data": "InventoryManager" },
                    { "data": "InventoryActive1",
                        "orderable": false,
                        "searchable": false,
                        "render": function(data,type,row,meta) { // render event defines the markup of the cell text 
                            var a = '<a><i class="fa fa-edit"></i>  ' + row.InventoryName +'</a>'; // row object contains the row data
                            return a;
                        }
                    }
            ]
        });
    });
$(文档).ready(函数(){
$('#示例')。数据表({
“ajax”:yourDataURL,
“columns”:[//定义输出表的列
{“data”:“InventoryId”},//集合中项的属性
{“数据”:“InventoryName”},
{“数据”:“库存管理器”},
{“数据”:“InventoryActive1”,
“可订购”:错误,
“可搜索”:错误,
“渲染”:函数