Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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
Jquery 具有动态创建的表的datatable_Jquery_Asp.net_Datatables - Fatal编程技术网

Jquery 具有动态创建的表的datatable

Jquery 具有动态创建的表的datatable,jquery,asp.net,datatables,Jquery,Asp.net,Datatables,在ajax成功的内部,我正在尝试将行添加到已经存在的数据表中。追加成功了,但失去了datatable功能 请参考下面我的代码 $(document).ready(function () { $(document).on('click', '.btn-primary', function(evt){ evt.preventDefault() $.ajax({ type: "POST", url: "he

在ajax成功的内部,我正在尝试将行添加到已经存在的数据表中。追加成功了,但失去了datatable功能

请参考下面我的代码

    $(document).ready(function () {
       $(document).on('click', '.btn-primary', function(evt){ 
       evt.preventDefault()
       $.ajax({
           type: "POST",
           url: "hello.aspx/ProcessMe",
           data: '{id: "' + $(this).prev().val() + '" ,dept:"' + $(this).prev().prev().val() + '"}',
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           success: function (data) {  //variable 'data' will get a string array from 'ProcessMe' C# function
             if (typeof data != "undefined" && data.d !== null) {
              $("#grdAll").empty(); //grdAll is the id of my aspx gridview which was already a datatable that is being generated before this ajax call for some other purpose.
              //all rows cleared.. now i will append new records.

           $('#grdAll').append("<tr><th>blah</th><th>blah</th>  ....... </tr>");
               for (var i = 0; i < 1; i++) {
              $('#grdAll').append("<tr>" +
                 "<td>" + data.d[i + 1] + "</td>" + //getting array values
                  "<td>" + data.d[i + 2] + "</td>" +
                    ....................................//some script                           
"<td> <input type='hidden' name='blah' id='blah' value='" + data.d[i] + "'>" +
     "<a id='lnkProcess' class='btn btn-primary btn-round icnsml' data-original-title='' title='Process'>" +
  "<i class='fa fa-play-circle'></i>" +
 "</a>" 
 "</td>"
 );
 i++;
 }
    Now i am trying to make it as a datatable
   $('#grdAllTokens').DataTable({
............ //some code
  "retrieve": true
});
});
});
$(文档).ready(函数(){
$(文档).on('click','.btn primary',函数(evt){
evt.preventDefault()
$.ajax({
类型:“POST”,
url:“hello.aspx/ProcessMe”,
数据:“{id:”+$(this.prev().val()+”,dept:“+$(this.prev().prev().val()+”}”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:函数(data){//变量'data'将从'ProcessMe'C#函数中获取字符串数组
if(数据类型!=“未定义”&&data.d!==null){
$(“#grdAll”).empty();//grdAll是我的aspx gridview的id,它已经是一个数据表,在这个ajax调用之前出于其他目的生成。
//所有行已清除..现在我将附加新记录。
$('grdAll')。附加(“blahblah……);
对于(变量i=0;i<1;i++){
$('#grdAll')。追加(“”+
“”+data.d[i+1]+“”+//获取数组值
“”+data.d[i+2]+“”+
一些脚本
" " +
"" +
"" +
"" 
""
);
i++;
}
现在,我试图将其作为一个数据表
$('#grdAllTokens')。数据表({
一些代码
“检索”:true
});
});
});
但我没有成功地获得一个数据表。我看不到排序选项、样式等

但我可以看到datatble和页脚消息的搜索框已经存在,搜索将在页脚消息中生成正确的结果


例如,如果我在那里搜索“blahblahblah”,它将显示“显示0个条目中的0到0个(从1个总条目中筛选)”

@BrettCaswell我已经编辑了我的问题。很抱歉我的英语不好。希望现在能说清楚。我只希望新生成的表应该具有数据表功能,如排序、搜索等。该网站有很多文档和示例!是的。但我正试图以这种方式添加它。在收到数组变量后