Got the mulitcolumn search toolbar in place, but it's not working. First I haven't managed to get an autosearch working (searching as you type). Second, and much more critically, I don't have the controller correctly responding to search terms, as it was implemented rather poorly. I'm moving on for now.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@113 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -164,15 +164,25 @@ class AppController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function jqGridDataConditions(&$params) {
|
function jqGridDataConditions(&$params) {
|
||||||
|
$searches = array();
|
||||||
|
|
||||||
if (isset($params['_search']) && $params['_search'] === 'true') {
|
if (isset($params['_search']) && $params['_search'] === 'true') {
|
||||||
$op = $params['searchOper'];
|
if (isset($params['searchOper'])) {
|
||||||
$field = $params['searchField'];
|
$searches[] = array('op' => $params['searchOper'],
|
||||||
$string = $params['searchString'];
|
'field' => $params['searchField'],
|
||||||
|
'value' => $params['searchString']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// DOH! Crappy mechanism puts toolbar search terms
|
||||||
|
// directly into params as name/value pairs. No
|
||||||
|
// way to know which elements of params are search
|
||||||
|
// terms, so skipping this at the moment.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif (isset($params['filt']) && $params['filt']) {
|
elseif (isset($params['filt']) && $params['filt']) {
|
||||||
$op = 'bw';
|
$searches[] = array('op' => 'bw',
|
||||||
$field = $params['filtField'];
|
'field' => $params['filtField'],
|
||||||
$string = $params['filtString'];
|
'value' => $params['filtString']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return array();
|
return array();
|
||||||
@@ -189,10 +199,15 @@ class AppController extends Controller {
|
|||||||
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
|
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$op = $ops[$op];
|
$conditions = array();
|
||||||
$field .= $op['op'] ? ' '.$op['op'] : '';
|
foreach ($searches AS $search) {
|
||||||
$string = $op['pre'] . $string . $op['post'];
|
$op = $ops[$search['op']];
|
||||||
return array($field => $string);
|
$field = $search['field'] . ($op['op'] ? ' '.$op['op'] : '');
|
||||||
|
$value = $op['pre'] . $search['value']. $op['post'];
|
||||||
|
$conditions[] = array($field => $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function jqGridDataFields(&$params) {
|
function jqGridDataFields(&$params) {
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ $cols['Comment'] = array('index' => 'Customer.comment', 'width' =>
|
|||||||
foreach (array_intersect_key($cols, array('Comment'=>1)) AS $k => $v)
|
foreach (array_intersect_key($cols, array('Comment'=>1)) AS $k => $v)
|
||||||
$cols[$k]['sortable'] = false;
|
$cols[$k]['sortable'] = false;
|
||||||
|
|
||||||
|
// Some of the columns should be searchable
|
||||||
|
foreach (array_intersect_key($cols, array('Last Name'=>1, 'First Name'=>1)) AS $k => $v)
|
||||||
|
$cols[$k]['search'] = true;
|
||||||
|
|
||||||
// Create the javascript code for jqGrid to create each table column
|
// Create the javascript code for jqGrid to create each table column
|
||||||
$colModels = array();
|
$colModels = array();
|
||||||
foreach ($cols AS $col) {
|
foreach ($cols AS $col) {
|
||||||
@@ -43,7 +47,7 @@ foreach ($cols AS $col) {
|
|||||||
'{ ' . implode(", ",
|
'{ ' . implode(", ",
|
||||||
array_map(create_function
|
array_map(create_function
|
||||||
('$k, $v',
|
('$k, $v',
|
||||||
'return "$k:".($v===false?"false":"\'$v\'");'),
|
'return "$k:".($v===false?"false":($v===true?"true":"\'$v\'"));'),
|
||||||
array_keys($col),
|
array_keys($col),
|
||||||
array_values($col))) .
|
array_values($col))) .
|
||||||
'}';
|
'}';
|
||||||
@@ -70,8 +74,8 @@ $url = $html->url(array('controller' => 'customers',
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
jQuery(document).ready(function(){
|
jQuery(document).ready(function(){
|
||||||
// return;
|
|
||||||
jQuery("#customer-list").jqGrid({
|
jQuery("#customer-list").jqGrid({
|
||||||
url: '<?php echo $url; ?>',
|
url: '<?php echo $url; ?>',
|
||||||
datatype: 'xml',
|
datatype: 'xml',
|
||||||
@@ -89,21 +93,46 @@ jQuery(document).ready(function(){
|
|||||||
viewrecords: true,
|
viewrecords: true,
|
||||||
imgpath: '<?php echo $imgpath; ?>',
|
imgpath: '<?php echo $imgpath; ?>',
|
||||||
caption: <?php echo $caption ? "'$caption'" : "null"; ?>,
|
caption: <?php echo $caption ? "'$caption'" : "null"; ?>,
|
||||||
|
toolbar : [true,"bottom"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery("#t_customer-list").height(25).hide()
|
||||||
|
.filterGrid("#customer-list", {
|
||||||
|
gridModel:true,
|
||||||
|
gridToolbar:true,
|
||||||
|
autosearch:true,
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery("#customer-list").navGrid('#customer-pager',
|
||||||
|
{ view:false,
|
||||||
|
edit:false,
|
||||||
|
add:false,
|
||||||
|
del:false,
|
||||||
|
search:false,
|
||||||
|
refresh:false})
|
||||||
|
.navButtonAdd("#customer-pager",{
|
||||||
|
caption:"Search",
|
||||||
|
title:"Toggle Search",
|
||||||
|
buttonimg:'<?php echo $imgpath; ?>' + '/find.gif',
|
||||||
|
onClickButton:function(){
|
||||||
|
if(jQuery("#t_customer-list").css("display")=="none") {
|
||||||
|
jQuery("#t_customer-list").css("display","");
|
||||||
|
} else {
|
||||||
|
jQuery("#t_customer-list").css("display","none");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
<div id="everything">
|
|
||||||
<table id="customer-list" class="scroll"></table>
|
<table id="customer-list" class="scroll"></table>
|
||||||
<div id="customer-pager" class="scroll" style="text-align:center;"></div>
|
<div id="customer-pager" class="scroll" style="text-align:center;"></div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="h">Search By:</div>
|
<div>Search By:<BR>
|
||||||
<div>
|
<input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)">Enable Autosearch<BR>
|
||||||
<input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)">Enable Autosearch
|
Last Name<BR>
|
||||||
</div>
|
|
||||||
<div>Last Name<br>
|
|
||||||
<input type="text" id="filt_last_name" onkeydown="doSearch(arguments[0]||event)" />
|
<input type="text" id="filt_last_name" onkeydown="doSearch(arguments[0]||event)" />
|
||||||
<button onclick="gridReload()" id="submitButton" style="margin-left:30px;">Search</button>
|
<button onclick="gridReload()" id="submitButton" style="margin-left:30px;">Search</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -139,13 +168,3 @@ function gridReload() {
|
|||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
<?php
|
|
||||||
/* <div><a href="#" onClick="$('#debug').html(htmlEncode($('#everything').html())); return false;">Get Table Code</a></div> */
|
|
||||||
/* <div id="debug"></div> */
|
|
||||||
|
|
||||||
/* <P> */
|
|
||||||
/* <input type="text" id="debval" value="1.0em"><BR> */
|
|
||||||
/* <a href="#" onClick="$('#load_customer-list').css('display', 'inline'); return false;">Show Loading</a><BR> */
|
|
||||||
/* <a href="#" onClick="$('#load_customer-list').css('margin-top', $('#debval').val()); return false;">Set Top Margin</a><BR> */
|
|
||||||
/* <a href="#" onClick="$('#load_customer-list').css('margin-left', $('#debval').val()); return false;">Set Left Margin</a><BR> */
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user