RefreshDataTable not working after deleting row from datatable in v1.10.15 ?

RefreshDataTable not working after deleting row from datatable in v1.10.15 ?

RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0

Written in delete success like this,

objDataTable1.RefreshDataTable("dtdynList");

Answers

  • RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0
    edited May 2017

    .

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin

    What is the RefreshDataTable function? Is that one you've added yourself?

    DataTables 1.10 has a ajax.reload() method built in.

    Allan

  • RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0
    edited May 2017

    Thanks for response,

    Yes it's my own function.

    I tried DataTables 1.10 ajax.reload() too, but not working as expected.

    I need to refresh the datatables after deleting the row in datatable dynamically .

    which function I need to use ?

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin

    I tried DataTables 1.10 ajax.reload() too, but not working as expected.

    You are going to have to give me a lot more information than that I'm afraid. Ideally a link to the page showing the issue, per the forum rules.

    For example is there an Ajax error, or a Javascript error happening? Are you making an Ajax call to delete the row and then you want to reload the table? Are you using the ajax option to load the table? Give me something to work with :).

    Allan

  • RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0
    edited May 2017

    Thanks fro great response,

    I am using ajax call to delete the record from datatables ,in delete success method I am using ajax.reload() to reload the table.

    code:

    $.ajax
    ({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/WebServices/Common/DynamicFormService.asmx//DeleteRecordDelete",
    data: "{objDataTable1.GetSelectedRowIDs("dtdynList") }",
    success: function (data) {
    var table = $('#dtdynList').DataTable();
    table.ajax.reload()
    error: function (x, e) {
    alert("error");
    }
    });

    Even if I use ajax.reload() deleted record also showing in the table but record deleted in database.When I attempt hole page refresh then showing fresh data.

    suggest me if anything I am missing.

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin

    Right - so you aren't using DataTables' own ajax option. In that case ajax.reload() is basically meaningless since DataTables doesn't have any Ajax information with which to make a request to!

    If you have the data yourself, use clear() to remove the old data from the table and then rows.add() to add the new data. Finally use draw() to draw it.

    Allan

  • RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0

    In my above code how to use clear(),rows.add() and draw() functions
    can you provide the code plz?

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin
    t.clear();
    t.rows.add( ... );
    t.draw();
    

    Not difficult :)

    Allan

  • RameshKodamRameshKodam Posts: 12Questions: 3Answers: 0
    edited June 2017

    If you have the data yourself, use clear() to remove the old data from the table and then rows.add() to add the new data. Finally use draw() to draw it.

    I don't have data,in this case how do I refresh the datatables ?

    because I am getting error when I refresh the datatables in _fnCalculateColumnWidths method

    headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
    _fnStringToCss(column.sWidthOrig)

    Here HeaderCells showing as undefined, so getting error.

    And also I want the paging buttons like arrow icons instead of "first","next","last","previous" text , where do I need to change these buttons.

    any suggestion plz?

    Thanks

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin

    don't have data,in this case how do I refresh the datatables ?

    I'm not sure you would. What would you refresh it with if you don't have new data?

    because I am getting error when I refresh the datatables in _fnCalculateColumnWidths method

    Happy to look at a test case showing the issue.

    Allan

  • Abhi RAbhi R Posts: 17Questions: 5Answers: 0

    Hello
    After deleting it returning "OK".
    So now how to do?

  • allanallan Posts: 61,734Questions: 1Answers: 10,111 Site admin

    What was returning okay? What do you want to do next? Please link to a test case showing the issue with a full description of the issue.

    Thanks,
    Allan

This discussion has been closed.