this url :
http://php.speedmis.com/_mis/index.php?gubun=734&isMenuIn=Yinsert Filter : 166
result total count : 1.
why result many list?
and idx title click then only 1 list.
------------------------
html and javascript:
<script>
$(function () {
// 필터사용을 위한 함수
function filterhandler(evt, ui) {
$grid=$(".pq-grid");
var $toolbar = $grid.find('.pq-toolbar-search'),
$value = $toolbar.find(".filterValue"),
value = $value.val(),
condition = $toolbar.find(".filterCondition").val(),
dataIndx = $toolbar.find(".filterColumn").val(),
filterObject;
if (dataIndx == "") {//search through all fields when no field selected.
filterObject = [];
var CM = $grid.pqGrid("getColModel");
for (var i = 0, len = CM.length; i < len; i++) {
var dataIndx = CM
.dataIndx;
filterObject.push({ dataIndx: dataIndx, condition: condition, value: value });
}
}
else {//search through selected field.
filterObject = [{ dataIndx: dataIndx, condition: condition, value: value}];
}
$grid.pqGrid("filter", {
oper: 'replace',
data: filterObject
});
}
var pqVS = {
rpp: 100, //records per page.
init: function () {
this.totalRecords = 0;
this.requestPage = 1; //begins from 1.
this.data = [];
}
};
pqVS.init();
var obj = {
//width: 'flex', ---- 항상 필요 없음.
freezeCols: 3, //좌측 칼럼3~4개 틀고정
//scrollModel: { autoFit: true }, //일정폭 이상이 되면 해당 코딩 제외!!
numberCell: { width: 50, resizable: true, title: "#" },
title: "Virtual Scrolling",
virtualX: true,
virtualY: true,
resizable: true,
//move paging toolbar to top in create event callback.
/*
//아래는 페이징쓸때 고려해보라.
pageModel: { type: "local", rPP: 20, strRpp: "{0}", strDisplay: "{0} to {1} of {2}" },
create: function (ui) {
var $pager = this.pager().widget();
if ($pager && $pager.length) {
$pager = $pager.detach();
this.widget().find(".pq-grid-top").append($pager);
}
},
showBottom: false,
*/
//필터툴바를 위한 준비 --------------------------------
filterModel: { mode: 'OR', type: "remote" },
toolbar: {
cls: "pq-toolbar-search",
items: [
{ type: "<span style='margin:5px;'>Filter</span>" },
{ type: 'textbox', attr: 'placeholder="Enter your keyword"', cls: "filterValue", listeners: [{ 'change': filterhandler}] },
{ type: 'select', cls: "filterColumn",
listeners: [{ 'change': filterhandler}],
options: function (ui) {
var CM = ui.colModel;
var opts = [{ '': '[ All Fields ]'}];
for (var i = 0; i < CM.length; i++) {
var column = CM;
var obj = {};
obj[column.dataIndx] = column.title;
opts.push(obj);
}
return opts;
}
},
{ type: 'select', style: "margin:0px 5px;", cls: "filterCondition",
listeners: [{ 'change': filterhandler}],
options: [
{ "begin": "Begins With" },
{ "contain": "Contains" },
{ "end": "Ends With" },
{ "notcontain": "Does not contain" },
{ "equal": "Equal To" },
{ "notequal": "Not Equal To" },
{ "empty": "Empty" },
{ "notempty": "Not Empty" },
{ "less": "Less Than" },
{ "great": "Great Than" }
]
}
]
},
sortModel: { type: 'remote', sorter: [{ dataIndx: 'idx', dir: 'up'}] },
beforeSort: function (evt) {
if (evt.originalEvent) {//only if sorting done through header cell click.
pqVS.init();
}
},
beforeTableView: function (evt, ui) {
var initV = ui.initV,
finalV = ui.finalV,
data = pqVS.data,
rpp = pqVS.rpp,
requestPage;
if (initV != null) {
//if records to be displayed in viewport are not present in local cache,
//then fetch them from remote database/server.
if (data[initV] && data[initV].pq_empty) {
requestPage = Math.floor(initV / rpp) + 1;
}
else if (data[finalV] && data[finalV].pq_empty) {
requestPage = Math.floor(finalV / rpp) + 1;
}
if (requestPage >= 1) {
if (pqVS.requestPage != requestPage) {
pqVS.requestPage = requestPage;
//initiate remote request.
this.refreshDataAndView();
}
}
}
}
};
//[{"dataIndx":"Grid_TextMatrix0","dir":"down"}]
obj.colModel = [
//체크기능을 옵션에 의해 넣고/안넣기 : simpleList
{ dmaxWidth: 30, minWidth: 30, align: "center", resizable: false,
type: 'checkBoxSelection', cls: 'ui-state-default', sortable: false, editor: false,
dataType: 'bool',
cb: {
all: false, //checkbox selection in the header affect current page only.
header: true //show checkbox in header.
}
},
//상단 타이틀 3단구성 - 프로그램 정보(2단만)
{ title: "프로그램 정보",align: "center", colModel: [
{ title: "idx", width:200, dataType: "float", dataIndx: 'idx'},
{ title: "RealPid", width:200, dataType: "textbox", dataIndx: 'RealPid' }]},
{ title: "항목 정보", width:200, align: "center", colModel: [
{ title: "RealDid", width:200, dataType: "textbox", dataIndx: 'RealDid' },
{ title: "순번", width:200, dataType: "textbox", dataIndx: 'SortElement' },
{ title: "항목명", width:200, dataType: "textbox", dataIndx: 'Grid_TextMatrix0' },
{ title: "테이블구분자", width:200, dataType: "textbox", dataIndx: 'Grid_Tname' },
{ title: "필드명", width:200, dataType: "textbox", dataIndx: 'Grid_FieldName' },
{ title: "알림문구", width:1000, dataType: "textbox", dataIndx: 'Grid_alim' },
{ title: "표시형식", width:200, dataType: "textbox", dataIndx: 'Grid_Format' },
{ title: "입력컨트롤", width:200, dataType: "textbox", dataIndx: 'Grid_CtlName' },
{ title: "transID", width:200, dataType: "textbox", dataIndx: 'transID' }
]}
];
obj.dataModel = {
dataType: "JSON",
location: "remote",
method: "POST",
url: "/_json/json_test2.php",
postData: function () {
return {
pq_curpage: pqVS.requestPage,
pq_rpp: pqVS.rpp
};
},
getData: function (response) {
var data = response.data,
totalRecords = response.totalRecords,
len = data.length,
curPage = response.curPage,
pq_data = pqVS.data,
init = (curPage - 1) * pqVS.rpp;
if (!pqVS.totalRecords) {
//first time initialize the rows.
for (var i = len; i < totalRecords; i++) {
pq_data[i + init] = { pq_empty: true };
}
pqVS.totalRecords = totalRecords;
}
for (var i = 0; i < len; i++) {
pq_data[i + init] = data;
pq_data[i + init].pq_empty = false;
}
//return { data: response.data }; //이건 내가 바꿔본건데, 이걸로하면 무한스크롤 안됨.
return { data: pq_data }
},
error: function (jqXHR, textStatus, errorThrown) {
//alert(errorThrown);
}
};
$("#grid_infinite").pqGrid(obj);
});
</script>
<div id="grid_infinite" style="margin: auto;">
</div>
=======================================
json :
$filterQuery = "";
$filterParam = array();
if ( isset($_POST["pq_filter"]))
{
$pq_filter = $_POST["pq_filter"];
$dsf = FilterHelper::deSerializeFilter($pq_filter);
$filterQuery = $dsf->query;
$filterParam = $dsf->param;
}
//orders.php
$sortQuery = "";
if(isset($_POST["pq_sort"]))
{
$pq_sort = $_POST["pq_sort"];
$sortQuery = SortHelper::deSerializeSort($pq_sort);
}
$cpg = $_REQUEST[ "pq_curpage" ];
$rpp = $_REQUEST[ "pq_rpp" ];
$sql = "Select count(*) from mismenulist_detail " . $filterQuery;
$dsn = 'mysql:host='.DB_HOSTNAME.';dbname='.DB_NAME;
$optn = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', );
$dbh = new PDO( $dsn, DB_USERNAME, DB_PASSWORD, $optn );
//$stmt = $dbh->query( $sql );
$stmt = $dbh->prepare($sql);
$stmt->execute($filterParam);
$totRec = $stmt->fetchColumn();
$skip = ( $rpp * ( $cpg - 1 ) );
if ( $skip >= $totRec )
{
$cpg = ceil( $totRec / $rpp );
$skip = ( $rpp * ( $cpg - 1 ) );
}
$sql = "select idx, RealDid, RealPid, Grid_TextMatrix0, SortElement, Grid_Tname, Grid_FieldName, Grid_alim, Grid_Format, Grid_CtlName, left(transID,3) as transID from mismenulist_detail " . $filterQuery . $sortQuery;
if($totRec > 0) $sql = $sql . " limit " . $skip . " , " . $rpp;
//$stmt = $dbh->query( $sql );
$stmt = $dbh->prepare($sql);
$stmt->execute($filterParam);
$rows = $stmt->fetchAll( PDO::FETCH_ASSOC );
$sb = "{\"totalRecords\":" . $totRec . ",\"curPage\":" . $cpg . ",\"data\":" . json_encode( $rows ) . "}";
//echo $filterParam[0];
echo $sb;