Commit d288cf6394c4cdb690073a4fecb3fd8142d754d1

Authored by David RENÉ
1 parent f1320120

[+] improvement of the number (count) returned for jqgrid

Showing 1 changed file with 9 additions and 4 deletions   Show diff stats
src/web_controller/hayamiki.anubis
... ... @@ -208,7 +208,9 @@ define (WEB_Session) -> WEB_Controller_Result
208 208 "("+_filter.filter_string+") AND "+_clause,
209 209  
210 210 println("grid_view_json final clause : ["+clause+"])");
211   - with number = controller.get_count(db, if clause = "" then "" else "WHERE "+clause),
  211 + with referer_count = if referer is {no_referer then "", hk_referer(_, row_id, _, column) then (if clause = "" then "" else " AND ")+column+"="+row_id},
  212 + println("referer_count ["+referer_count+"]");
  213 + with number = controller.get_count(db, if clause = "" & referer_count = "" then "" else " WHERE "+ clause + referer_count),
212 214  
213 215 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,
214 216 with new_page = if total_page < page then total_page else page,
... ... @@ -313,7 +315,7 @@ define (WEB_Session) -&gt; WEB_Controller_Result
313 315 with search_clause = if length(active_filter_clause) > 0 then _search_clause + " AND ("+active_filter_clause+") " else _search_clause,
314 316  
315 317 println("combo_search final clause : ["+search_clause+"])");
316   - with number = controller.get_count(db, if search_clause = "" then "" else "WHERE "+search_clause),
  318 + with number = controller.get_count(db, if search_clause = "" then "" else " WHERE "+search_clause),
317 319 //OFFSET
318 320 with offset = (page-1) * limit,
319 321 //ORDER BY
... ... @@ -526,7 +528,7 @@ define (WEB_Session) -&gt; WEB_Controller_Result
526 528 limit = get_Int(lwa, "rows", 0),
527 529 page = get_Int(lwa, "page", 1),
528 530 sord = get_String(lwa, "sord", "asc"),
529   - sidx = get_String(lwa, "sidx", "id"),
  531 + sidx = get_String(lwa, "sidx", "id"), //sort id
530 532 clause = get_String(lwa, "clause", "1 = 1"),
531 533 referer = get_HK_Referer_from_web_arg(lwa, ""),
532 534  
... ... @@ -535,7 +537,10 @@ define (WEB_Session) -&gt; WEB_Controller_Result
535 537 // println("_filter query: "+_filter.filter_string);
536 538 // with clause = if _filter.filter_string = "" then "" else if _clause = "" then _filter.filter_string else "("+_filter.filter_string+") AND "+_clause,
537 539 println("get_rows_json final clause : ["+clause+"])");
538   - with number = controller.get_count(db, if clause = "" then "" else "WHERE "+clause),
  540 + with referer_count = if referer is {no_referer then "", hk_referer(_, row_id, _, column) then (if clause = "" then "" else " AND ")+column+"="+row_id},
  541 + println("referer_count ["+referer_count+"]");
  542 +// with number = controller.get_count(db, if clause = "" then "" else "WHERE "+ clause + referer_count),
  543 + with number = controller.get_count(db, if clause = "" & referer_count = "" then "" else " WHERE "+ clause + referer_count),
539 544  
540 545 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,
541 546 with new_page = if total_page < page then total_page else page,
... ...