From d288cf6394c4cdb690073a4fecb3fd8142d754d1 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 27 Nov 2021 08:36:52 +0100 Subject: [PATCH] [+] improvement of the number (count) returned for jqgrid --- src/web_controller/hayamiki.anubis | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/web_controller/hayamiki.anubis b/src/web_controller/hayamiki.anubis index 8d8f410..904e62a 100644 --- a/src/web_controller/hayamiki.anubis +++ b/src/web_controller/hayamiki.anubis @@ -208,7 +208,9 @@ define (WEB_Session) -> WEB_Controller_Result "("+_filter.filter_string+") AND "+_clause, println("grid_view_json final clause : ["+clause+"])"); - with number = controller.get_count(db, if clause = "" then "" else "WHERE "+clause), + with referer_count = if referer is {no_referer then "", hk_referer(_, row_id, _, column) then (if clause = "" then "" else " AND ")+column+"="+row_id}, + println("referer_count ["+referer_count+"]"); + with number = controller.get_count(db, if clause = "" & referer_count = "" then "" else " WHERE "+ clause + referer_count), with total_page = if number/limit is success(result) then since result is (pages, fraction), pages + if fraction > 0 then 1 else 0 else 1, with new_page = if total_page < page then total_page else page, @@ -313,7 +315,7 @@ define (WEB_Session) -> WEB_Controller_Result with search_clause = if length(active_filter_clause) > 0 then _search_clause + " AND ("+active_filter_clause+") " else _search_clause, println("combo_search final clause : ["+search_clause+"])"); - with number = controller.get_count(db, if search_clause = "" then "" else "WHERE "+search_clause), + with number = controller.get_count(db, if search_clause = "" then "" else " WHERE "+search_clause), //OFFSET with offset = (page-1) * limit, //ORDER BY @@ -526,7 +528,7 @@ define (WEB_Session) -> WEB_Controller_Result limit = get_Int(lwa, "rows", 0), page = get_Int(lwa, "page", 1), sord = get_String(lwa, "sord", "asc"), - sidx = get_String(lwa, "sidx", "id"), + sidx = get_String(lwa, "sidx", "id"), //sort id clause = get_String(lwa, "clause", "1 = 1"), referer = get_HK_Referer_from_web_arg(lwa, ""), @@ -535,7 +537,10 @@ define (WEB_Session) -> WEB_Controller_Result // println("_filter query: "+_filter.filter_string); // with clause = if _filter.filter_string = "" then "" else if _clause = "" then _filter.filter_string else "("+_filter.filter_string+") AND "+_clause, println("get_rows_json final clause : ["+clause+"])"); - with number = controller.get_count(db, if clause = "" then "" else "WHERE "+clause), + with referer_count = if referer is {no_referer then "", hk_referer(_, row_id, _, column) then (if clause = "" then "" else " AND ")+column+"="+row_id}, + println("referer_count ["+referer_count+"]"); +// with number = controller.get_count(db, if clause = "" then "" else "WHERE "+ clause + referer_count), + with number = controller.get_count(db, if clause = "" & referer_count = "" then "" else " WHERE "+ clause + referer_count), with total_page = if number/limit is success(result) then since result is (pages, fraction), pages + if fraction > 0 then 1 else 0 else 1, with new_page = if total_page < page then total_page else page, -- libgit2 0.21.4