最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - fnGetPosition is not a function-datatables - Stack Overflow

programmeradmin1浏览0评论

Friends ,I am trying to update my datatable as soon as i make an edit using jeditable.So that the new data get updated in the datatable and whenever i search for it ,it should be visible in the search result .But presently everything is working fine but the only problem is that whenever i edit something and search for the new edited value then the search result shows-no result found. In order to overe this i used the following code but now it gives me error saying -"fnGetPosition is not a function".Here is the code-

$(document).ready(function(){
  var table1 = $('#tasksheet').DataTable();
   table1.$('.edit_areaD<?php echo $row["id"]; ?>').editable('savetask.php', {
          id: 'element_id',
          name: 'dhanraj',
          indicator : 'Saving...',
          placeholder: "",
         onblur:'submit',
          cssclass: 'textheight',
         tooltip   : 'click to edit...',
  "callback": function( sValue, y ) {
            var aPos = table1.fnGetPosition( this );
            table1.fnUpdate( sValue, aPos[0], aPos[1] );
        },
        "submitdata": function ( value, settings ) {
            return {
                "row_id": this.parentNode.getAttribute('id'),
                "column": table1.fnGetPosition( this )[2]
            };
        },
     });
});
});

Thanks in advance.

Friends ,I am trying to update my datatable as soon as i make an edit using jeditable.So that the new data get updated in the datatable and whenever i search for it ,it should be visible in the search result .But presently everything is working fine but the only problem is that whenever i edit something and search for the new edited value then the search result shows-no result found. In order to overe this i used the following code but now it gives me error saying -"fnGetPosition is not a function".Here is the code-

$(document).ready(function(){
  var table1 = $('#tasksheet').DataTable();
   table1.$('.edit_areaD<?php echo $row["id"]; ?>').editable('savetask.php', {
          id: 'element_id',
          name: 'dhanraj',
          indicator : 'Saving...',
          placeholder: "",
         onblur:'submit',
          cssclass: 'textheight',
         tooltip   : 'click to edit...',
  "callback": function( sValue, y ) {
            var aPos = table1.fnGetPosition( this );
            table1.fnUpdate( sValue, aPos[0], aPos[1] );
        },
        "submitdata": function ( value, settings ) {
            return {
                "row_id": this.parentNode.getAttribute('id'),
                "column": table1.fnGetPosition( this )[2]
            };
        },
     });
});
});

Thanks in advance.

Share Improve this question asked Oct 28, 2016 at 5:12 payal_sutharpayal_suthar 4559 silver badges34 bronze badges 5
  • Well ,even i thought that it should be .dataTable() instead of .DataTable() .But when i change it to .dataTable() it says table1.search is not a function.@JaromandaX – payal_suthar Commented Oct 28, 2016 at 5:21
  • we.. then suggest me a better way of doing that..because as far as now ..i got only this..@JaromandaX – payal_suthar Commented Oct 28, 2016 at 5:23
  • yes i am getting fnGetPostion is not a function@JaromandaX – payal_suthar Commented Oct 28, 2016 at 5:24
  • Let us continue this discussion in chat. – payal_suthar Commented Oct 28, 2016 at 5:29
  • Its solved i used a bit of different way as for search it requires .DataTable() and for fnGetPosition it requires .datatable() so i reinitialized it for search thanks any ways @JaromandaX – payal_suthar Commented Oct 28, 2016 at 5:31
Add a ment  | 

2 Answers 2

Reset to default 3

Well after a long struggle and with the help of JaromandaX.Here is the answer. change this-

 var table1 = $('#tasksheet').DataTable();

to this-

 var table1 = $('#tasksheet').dataTable();

For a better explanation about this:

The difference using DataTable() VS Using datatable():

The difference between the two is that the first will return a jQuery object, while the second returns a DataTables API instance.

Following https://datatables/upgrade/1.10-convert:

To get the index via datatable() you'll need to use the fnGetPosition function.

To get the same via DataTable() you'll need to use row().index(): https://datatables/reference/api/row().index()

发布评论

评论列表(0)

  1. 暂无评论