Possible bug in the draw function

Possible bug in the draw function

madrianmadrian Posts: 4Questions: 1Answers: 0

I am using YADCF plugin with Datatables and I found a little glitch. I am trying to update a selector, but table_arg.fnDraw inside exFilterColumn function is reseting select filter value.

yadcf.initOnDtXhrComplete(function() { 
      yadcf.exFilterColumn(oTable, [[4, $("#yadcf-filter--mytable-4 option:eq(1)").val()]], true); 
   });

Daniel, developer of YADCF who has discovered the bug on Stackoverflow.

You can check on website https://bow.thingiverse.ml

Answers

  • kthorngrenkthorngren Posts: 7,336Questions: 22Answers: 1,616
    edited January 9

    That was fun, I hadn't looked at YADCF for awhile. Took a bit to figure out how yadcf.exFilterColumn works :smile:

    Not sure how the Datatables draw() API would affect the YADCF created input. Datatables has no knowledge of it.

    I built a simpler test case to replicate your issue:
    http://live.datatables.net/cecegoco/1/edit

    The problem, in my case, is actually with the yadcf.initOnDtXhrComplete event. It doesn't seem to work with server side processing. Likely it will work with client side ajax loaded tables. Although the behavior is a bit different then your example it highlights the issue. You can see that the event keeps running after each server side XHR response causing another search/response. The YADCF developer might be able to create a way to invoke that event once like one().

    One option is to use the init event which will execute after all the data is loaded and Datatables is finished initializing. This can be seen here:
    http://live.datatables.net/rekivubo/1/edit

    Kevin

  • madrianmadrian Posts: 4Questions: 1Answers: 0

    For some reason it doesn't work for me with init:

    $('#mytable').on( 'init.dt', function () {
         yadcf.exFilterColumn(oTable, [[4, '2/2020']], true);
     });
    

    I found one more problem: I am using the "Pipelining data to reduce Ajax calls for paging". It works pretty good If I am going forward in pages, but when I click to the last page and I am trying to go back I am getting empty result/or loading message. I tried with/without ysdcf, the problem is not with this module. I think it is the same problem with Show X result: I choose show 100 record and nothing happens. If I choose 50, first page is showing correctly, but not the others. I think it's something with page caching?

  • kthorngrenkthorngren Posts: 7,336Questions: 22Answers: 1,616

    For some reason it doesn't work for me with init:

    Did you change the table selector ID from #mytable to match your table's ID?

    It works pretty good If I am going forward in pages, but when I click to the last page and I am trying to go back I am getting empty result/or loading message.

    This doesn't have anything to do with YADCF. You can see the problem with the browser's Developer Tools > Network tab. Watch the XHR requests. Load the page you will see two requests; the first is the initial request then the second is the YADCF search value:

    columns[4][data]: week
    columns[4][name]: 
    columns[4][searchable]: true
    columns[4][orderable]: true
    columns[4][search][value]: 2/2020
    columns[4][search][regex]: false
    

    You can page through page 5 without an XHR request. This is due to the Pipelining. Clicking page 6 fetches another set of pipelined pages. Clicking on 478 I see an XHR request and response and the page displays. Clicking on 477 there is a request for:

    start: 4720
    length: 50
    

    There is a 200 OK response but no data. The place to start is to see why the server script is not sending data in the response. Go back to page 1 and it works fine.

    Kevin

Sign In or Register to comment.