Author Topic: API strategy for mixing remote sorting, paging and filtering  (Read 2401 times)

mewbie

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 33
    • View Profile
API strategy for mixing remote sorting, paging and filtering
« on: January 05, 2018, 02:51:22 pm »
Hello Paramvir,

Sorry to make a thread again on the same setup,
but all of them now can be seen in here, could you take a look?

http://masterplan.pw/

Right now remote sorting is not working and acting funny if you click at the header and I suspected it mixed up with remote filtering API (and perhaps remote paging),
also I need to make header filter with 'AND' filter while toolbar filter with 'OR', can it be done? right now can only be done with one of them.

The other thing is the extra column to fill the flex detail grid,
I couldn't reproduce in the plunkr even with the same settings,
maybe it has something to do with javascript-detect-element-resize/jquery.resize.js ?

Here's the updated plurk (cannot reproduce) :
https://plnkr.co/edit/LOvrSsYMvqgaUo4BXyj9?p=preview

and here's my API code :

Code: [Select]
// other settings for job and classes

  // Execute job to get all tickets
    if($job == 'get_tickets')
    {
      if (isset($_GET["pq_curpage"]) && isset($_GET["pq_rpp"]) ){
        $filterQuery = "";
        $filterParam = array();
        if ( isset($_GET["pq_filter"]))
        {     
            $pq_filter = $_GET["pq_filter"];
            $dsf = FilterHelper::deSerializeFilter($pq_filter);
            $filterQuery = $dsf->query;
            $filterParam = $dsf->param;
        }
        if (isset($_GET["pq_sort"])) {
        $pq_sort = $_GET["pq_sort"];
        $sortQuery = SortHelper::deSerializeSort($pq_sort);
        }

        $pq_curPage = $_GET["pq_curpage"];
        $pq_rPP=$_GET["pq_rpp"];

        $sql = "Select count(*) from noc_tickets";
        $stmt = $dbh->query($sql);   
        $total_Records = $stmt->fetchColumn();     
        $skip = ($pq_rPP * ($pq_curPage - 1));

        if ($skip >= $total_Records)
        {       
            $pq_curPage = ceil($total_Records / $pq_rPP);
            $skip = ($pq_rPP * ($pq_curPage - 1));
        }
        // Get tickets
        $sql ="SELECT * FROM noc_tickets ORDER BY `TicketNo` DESC limit ".$skip." , ".$pq_rPP." ".$filterQuery;
          if ( isset($_GET["pq_filter"]))
          {       
          $sql = "SELECT * FROM noc_tickets ORDER BY `TicketNo` DESC" .$filterQuery;
          }
          if ( isset($_GET["pq_filter"]))
          {
           $sql ="SELECT * FROM noc_tickets".$sortQuery;
          }
        $stmt = $dbh->prepare($sql);
        $stmt->execute($filterParam);
        if (!$stmt){
          $result  = 'error';
          $message = 'query error';
        } else {
          $result  = 'success';
          $message = 'query success';
          $mysql_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
        }
      }
      // Prepare data
      $data = array(
      "result"  => $result,
      "message" => $message,
      "totalRecords" => $total_Records,
      "curPage" => $pq_curPage,
      "data"    => $mysql_data,
      );
      // Convert PHP array to JSON array
      $json_data = json_encode($data);
      print $json_data;
    }

Thank you

mewbie

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: API strategy for mixing remote sorting, paging and filtering
« Reply #1 on: January 06, 2018, 07:38:13 pm »
Just want to make a quick update for progress so far,

  • sorting, filtering, and paging remotely is already working, except for DATE (duration) filtering, cannot adjust with yyyy-mm-dd format.
  • still trouble with combining toolbar and header filtering functionality
  • still trouble with detail grid extra flexed column

thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: API strategy for mixing remote sorting, paging and filtering
« Reply #2 on: January 08, 2018, 12:31:03 pm »
Please avoid adding multiple questions / issues in a single post, it's one question per post.

Your last question about remote between filter condition has been split and answered here: https://paramquery.com/forum/index.php?topic=2506.0

The encircled part of the grid in your screenshot is not a column, but background of header. If you want to avoid empty space, please use width: 'flex' or scrollModel: {autoFit: true}
« Last Edit: January 08, 2018, 09:48:24 pm by paramquery »

mewbie

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: API strategy for mixing remote sorting, paging and filtering
« Reply #3 on: January 10, 2018, 02:25:46 pm »
Works like a charm, thank you very much