Author Topic: Filter update issue  (Read 2335 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Filter update issue
« on: April 13, 2018, 01:48:42 am »
Have everything remote, PHP/MySQL.
I filter a column that gives no match and then remove the filter at once (holding backspace and release it after all text is erased).

column settings: (datatype: 'string', type: 'textbox', condition: 'contain', listener: 'keyup')

I get back correct count (nr of rows) for the data but not the data itself from db (where all data should be returned since no filter is applied).
If the filtering gave a match from the beginning this does not happen.

If I delete the filter value by mutiple backspaces, it works from 2nd time backspace is pressed.

To wrap it up it seems if a filtering did not gave a match the db response is missing the data if removing the filter all at once...

Any idea what could be wrong?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Filter update issue
« Reply #1 on: April 13, 2018, 10:40:15 pm »
Couldn't reproduce it at my end with similar settings.

It would be easier to spot the cause of issue if you could share a test case / jsfiddle.

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter update issue
« Reply #2 on: April 17, 2018, 12:15:25 am »
Seems like this part causes the issue in my PHP. I run it to update the filtred total records before echoing the results.

Code: [Select]
$sql = "SELECT count(*) FROM test" . $filterQuery;
$stmt = $conn->prepare($sql);
$stmt->execute($filterParam);
$total_Records = $stmt->fetchColumn();

1. Filtering - 1 Match, Response: {"totalRecords":1,"curPage":1,"data":[{... --CORRECT
2. Filtering - 0 Match, Response: {"totalRecords":0,"curPage":1,"data":[]} --CORRECT
3. Filtering (back to same filter value as 1) - 0 Match, Response: {"totalRecords":1,"curPage":0,"data":[]} --INCORRECT

No 3, should give same response as 1, also why do curPage get requested with value 0?

If I remove above code, everything works fine. Any idea? Sorry no jsfiddle available atm.



« Last Edit: April 17, 2018, 01:30:15 am by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Filter update issue
« Reply #3 on: April 17, 2018, 12:24:51 pm »
Oh ok, so that problem is caused by grid sending 0 as curPage.

It's important to check boundary conditions in remote script so that curPage is not < 1 and not > total pages  ( I would add it in the documentation )

Code: [Select]
    $pq_curPage = $pq_curPage > 0 ? $pq_curPage : 1;

Code: [Select]
    $skip = ($pq_rPP * ($pq_curPage - 1));

    if ($skip >= $total_Records)
    {       
        $pq_curPage = ceil($total_Records / $pq_rPP);
        $skip = ($pq_rPP * ($pq_curPage - 1));
    }   

2nd check is already there in online scripts.
« Last Edit: April 17, 2018, 12:27:02 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter update issue
« Reply #4 on: April 17, 2018, 12:52:15 pm »
Works fine.
Thanks.