Request for Example: List view with Search box

thread: 3 messages  |  last: about 7 years ago  |  started: thursday, march 9, 2006, 3:56 pm pst

#1  |  alderete (San Francisco, CA)
Thursday, March 9, 2006, 3:56 PM PST

I was thinking that a great example would be a list view similar to the Issue Tracker from the demo video, but instead of (or in addition to) the two pop-up menus which filter results, having a search box that would allow you to search for a string appearing in the Issue, similarly filtering results.

A simple example would do the search based on only one field. A more complete example would search for the string across several fields, e.g., the short and long descriptions in the Issue Tracker example.

It would be cool to see AJAX and non-AJAX versions, but personally, I think the non-AJAX version would be more generally useful, since filtering and updating the whole list in realtime with typing into the search box seems like a recipe for performance jerkiness / ugliness (ala Spotlight searching in Mac OS X).

#2  |  Doug Mayer (St. Louis, MO)
Friday, March 10, 2006, 9:12 AM PST

A search box is just the matter of adding a QTextBox and QButton, and making an event on the QButton to set a datagrid/etc's DataSource.

For text searching, you have to make a custom LoadArrayBySearchString() and CountBySearchString().  

I use this for an e-commerce product search to match fulltext searches by SKU, Name, and Description.  In my LoadArrayBy, I take the search string and pass it to SqlVariable (after I parse it with PrepareSearchString for matching how I like it--below):
$strSearch = QApplication::$Database[1]->SqlVariable(self::PrepareSearchString($strSearch));

Then just add the following string to the query in your custom LoadArrayBy function:
sprintf('MATCH (`product`.`sku`,`product`.`name`,`product`.`description`) AGAINST (“%s” IN BOOLEAN MODE)', $strSearch);

The problem is Qcodo maintains to be database-neutral, and every database handles such searches in its own way.  I'm not sure how this would work out on the examples site.  There are already datagrid controls, etc... the only difference would be you'd have the textbox to type your term in, and use your custom filtering function to load your data.

(included for completeness)
private static function PrepareSearchString($strSearch) {
  if (strlen($strSearch) < 3) return '';
     $delimiters = ',.; ';
     $word = strtok($strSearch, $delimiters);
     $words = array();
     while ($word) {
     $words[] = $word;
     $word = strtok($delimiters);

  $temp_string = $words[0];
  if (count($words) > 1) {
     for ($i = 1; $i < count($words); $i++) {
        $temp_string .= ' '.$words[$i];
  return $temp_string;

#3  |  Mono Setiyaji (Indonesia) Indonesia
Tuesday, April 5, 2011, 7:04 AM PDT


Copyright © 2005 - 2019, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.