Page 7 of 104 FirstFirst ... 567891757 ... LastLast
Results 61 to 70 of 1037

Thread: Grid Search Plugin for Ext 4.x [updated]

  1. #61
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    8
      0  

    Default

    Quote Originally Posted by teknaut View Post
    Hmm, thanks for that it was to do with my return data as you have saisd. If I echo out {"success":true,"totalCount":"0","rows":[]} as my responsethe grid clears as expected. I will have to modify the return somehow.

    Thanks very much for your help.
    You might be interested in something like this (see "LOOK HERE"):
    PHP Code:
    function showData($dbTable
    {
    //    debugBreak();

        
    global $taxRate;
        
         
    /* By specifying the start/limit params in ds.load 
          * the values are passed here
          * if using ScriptTagProxy the values will be in $_GET
          * if using HttpProxy      the values will be in $_POST (or $_REQUEST)
          * the following two lines check either location, but might be more
          * secure to use the appropriate one according to the Proxy being used
          */
        //offset  
        
    $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
        
    //the page size
        
    $end = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']);  


        
    //if remoteSort is true than we need to include an ORDER BY in our query
        //column to sort
        
    if(isset($_REQUEST['sort'])){
            
    $sort = (isset($_POST['sort']) ? $_POST['sort'] : $_GET['sort']);
        }
        
    //sort direction 'DESC' or 'ASC'  (Ext.js sends mysql syntax)
        
    if(isset($_REQUEST['dir'])){
            
    $dir = (isset($_POST['dir']) ? $_POST['dir'] : $_GET['dir']);  
        }
        
    $sortBy = isset($sort) ? $sort 'company';
        if(isset(
    $dir)) {
            
    $sortDir $dir;
        }
        else{
            
    $sortDir 'ASC';
        }
        
        
        
    //get the total number of records so we can return it back with the results
        //the total count is used by the paging toolbar to display the number of records
        
    $sql_count 'SELECT * FROM ' $dbTable;
        
    $result_count mysql_query($sql_count);
        
    $rows mysql_num_rows($result_count);

        
    //now we get the data we want to send back to populate the store
        //we LIMIT the data sent back using the parameters from the paging toolbar
        //we also ORDER BY so the data is presented in some rational order
        //  note: when using ORDER BY with LIMIT you'll probably want to make sure
        //        that the column(s) using ORDER BY are indexed
        
    $sql $sql_count .  ' ORDER BY ' $sortBy ' ' $sortDir ' LIMIT ' $start ', '$end;
        
    $result mysql_query($sql);
    ////////////////////
    ////  LOOK HERE ////
        //to properly update grid, we need to return an empty array not null
        //declare an empty array, so even if it's empty when it's encoded it will return
        //"results":[]
        
    $arr = array();

        
    //populate the array if the query found records
        
    while($rec mysql_fetch_array($resultMYSQL_ASSOC)){
            
    //these lines are to populate the tax column for the initial display
            //of the grid, any updates to the price are handled by another function below
            
    $price $rec['price'];
            
    $rec['tax'] = round($price * ($taxRate),2);
            
            
    $arr[] = $rec;
        };

        
        if (
    version_compare(PHP_VERSION,"5.2","<"))
        {    
            require_once(
    "./JSON.php"); //if php<5.2 need JSON class
            
    $json = new Services_JSON();//instantiate new json object
            
    $data=$json->encode($arr);  //encode the data in json format
        
    } else
        {
            
    $data json_encode($arr);  //encode the data in json format
        
    }

    //    $data = (is_null($data)) ? '[]' : $data;
        
        /* If using ScriptTagProxy:  In order for the browser to process the returned
           data, the server must wrap te data object with a call to a callback function,
           the name of which is passed as a parameter by the ScriptTagProxy. (default = "stcCallback1001")
           If using HttpProxy no callback reference is to be specified*/
        
    $cb = isset($_GET['callback']) ? $_GET['callback'] : '';
           
        
    //we defined in our reader that the total count will be named 'total' (see totalProperty)
         
    echo $cb '({"total":"' $rows '","results":' $data '})';

    }
    //end showData 

  2. #62
    Ext User
    Join Date
    Aug 2007
    Posts
    3
    Vote Rating
    0
      0  

    Default

    it's very good!

  3. #63
    Ext User
    Join Date
    Feb 2008
    Posts
    20
    Vote Rating
    0
      0  

    Default

    I am trying to use the checkIndexes to indicate that the first and second should be checked by default, but I think I am doing something wrong.

    mode: 'remote'
    ,iconCls: false
    ,checkIndexes: [0,1]

    Thanks

  4. #64
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    406
      0  

    Default

    It doesn't work with numerical indexes but with field names as specified by column model dataIndex. For example:

    checkIndexes:['persFirstName', 'persLastName']
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  5. #65
    Ext User
    Join Date
    Nov 2007
    Location
    Fountain Valley, CA, USA
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Hi Jozef,

    First thing... Great plugin!

    I added a new config value called 'alignment' to allow the plugin to be aligned left or right on the toolbar. I added the logic to the onRender function.

    PHP Code:
    // added to config defaults
    ,alignment:'left'


    // onRender
    if (this.alignment === 'right') {
        
    tb.addFill();
    }
    else {
        
    tb.addSeparator();

    Thanks,
    Don

  6. #66
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    406
      0  

    Default

    Perfect! Thank you.

    I would just give config property name align to be consistent with the rest of Ext (e.g. labelAlign)
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  7. #67

  8. #68
    Ext User
    Join Date
    Nov 2007
    Location
    Fountain Valley, CA, USA
    Posts
    30
    Vote Rating
    0
      0  

    Default

    Yeah, I was debating between using align or alignment. I notice some with a name like buttonAlign, labelAlign, etc... and some with just alignment.

    One additional thing I added was a minimum input length for the search text box. This is ideal to make sure the search doesn't bring back more than you want it to. The only thing I wasn't sure about was how to notify the user when then entered less than the minimum input length. I was thinking a message box might be too intrusive. Any ideas?

    PHP Code:
    // added to config defaults
    ,minInputLength:0


    // onTriggerSearch
    if (this.minInputLength && val.length this.minInputLength) {
        return;


  9. #69
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664
    Vote Rating
    406
      0  

    Default

    Well, it's questionable if it is really necessary, at least from my viewpoint where I work almost exclusively with large tables and paging. Therefore, I do not need to force user to type at-least-that-many-characters (search works on enter, escape and triggers) as I always return only pageSize number of records (but maybe 100 pages if he typed only "a").

    If I would be about to notify user about a number of character limits I would probably simply set minLength property of text field and I would not submit query if field was invalid.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  10. #70
    Ext User
    Join Date
    Nov 2007
    Location
    Fountain Valley, CA, USA
    Posts
    30
    Vote Rating
    0
      0  

    Default

    I was looking more from a performance/long running query point of view. Some of the tables I work with have close to 20 million records. To perform a wild card search on a single character (SELECT * FROM <tablename> WHERE <fieldname> LIKE '%a%') would cause a table or index scan of all 20 million records. I guess I want to save the user from themselves and to keep long running queries from occurring.

    I took your suggestion and added the following to the field creation within onRender. I also changed the config property from minInputLength to minLength.

    PHP Code:
    ,minLength:this.minLength this.minLength 

Page 7 of 104 FirstFirst ... 567891757 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •