We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9710
    • 24 Posts
    Hello,

    Is it possible to write an plain js filter for an extjs grid without sending queries to the db? I have a grid with several columns (title, description, ...) and want to implement an input field a user can use to search. I thought of something like a LIKE %word% using several columns.


    // changed title
      • 9710
      • 24 Posts
      *push*

      no one? :/
        • 17499 ☆ A M B ☆
        • 872 Posts
        Try this plugin http://gridsearch.extjs.eu/
        The doc is located here: http://www.extjs.eu/docs/ (in: ux -> grid ->search)
          • 9710
          • 24 Posts
          Thank you, that’s exactly I was looking for!

          But I can’t get it working. I was trying to implement it in Bruno’s xdbedit grid:

          Xdbedit.grid.Object = function(config) {
              config = config || {}; 
              this.sm = new Ext.grid.CheckboxSelectionModel();
                  Ext.applyIf(config,{
                  url: Xdbedit.config.connector_url
                  ,baseParams: { 
                              action: 'mgr/xdbedit/getList',
                                  configs: config.configs}
                  ,fields: ['id','name','image','description','published','deleted']
                  ,paging: true
                  ,autosave: false
                  ,remoteSort: true
                  ,primaryKey: 'id'
                  ,isModified : false
                  ,sm: this.sm    
                  ,columns: [this.sm,{
                      header: 'id'
                      ,dataIndex: 'id'
                      ,sortable: true
                      ,width: 50
                  },
          
          [...]
          
                  }]  
                  ,plugins:[new Ext.ux.grid.Search({
                          readonlyIndexes:['id', 'name', 'description']
                          ,disableIndexes:['published', 'deleted']
                          ,minChars:2
                          ,autoFocus:true
          //              ,menuStyle:'radio'
                  }), this.rowActions]
          ,tbar: [
          
          [...]
          Line 143/144/145:
          
          );
          Xdbedit.grid.Object.superclass.constructor.call(this,config)
          this.getStore().on('load',this.onStoreLoad,this);
          


          But that gives me only following error:

          Uncaught exception: TypeError: Cannot convert 'a' to object
          
          Error thrown at line 7, column 265452 in <anonymous function: initPlugin>(a) in /manager/assets/ext3/ext-all.js:
              if(a.ptype&&!Ext.isFunction(a.init))
          called from line 7, column 263441 in <anonymous function: Ext.Component>(b) in /manager/assets/ext3/ext-all.js:
              this.plugins[c]=this.initPlugin(this.plugins[c])
          called from line 7, column 2919 in <anonymous function>() in /manager/assets/ext3/adapter/ext/ext-base.js:
              H.apply(this,arguments)
          called from line 7, column 2919 in <anonymous function>() in /manager/assets/ext3/adapter/ext/ext-base.js:
              H.apply(this,arguments)
          called from line 7, column 2919 in <anonymous function>() in /manager/assets/ext3/adapter/ext/ext-base.js:
              H.apply(this,arguments)
          called from line 7, column 2919 in <anonymous function>() in /manager/assets/ext3/adapter/ext/ext-base.js:
              H.apply(this,arguments)
          called from line 7, column 2919 in <anonymous function>() in /manager/assets/ext3/adapter/ext/ext-base.js:
              H.apply(this,arguments)
          called from line 21, column 107311 in <anonymous function: MODx.grid.Grid>(A) in /manager/assets/modext/modext-min.js?v=208pl:
              MODx.grid.Grid.superclass.constructor.call(this,A);
          called via Function.prototype.call() from line 144, column 4 in <anonymous function: Xdbedit.grid.Object>(config) in /assets/components/xdbedit/js/widgets/grids/team.grid.js?v=208pl:
              Xdbedit.grid.Object.superclass.constructor.call(this,config)
          called via Function.prototype.call() from line 7, column 262128 in <anonymous function: create>(d, e) in /manager/assets/ext3/ext-all.js:
              return d.render?d:new b[d.xtype||e](d)
          


          I’ve no clue what extjs is doing here..
            • 4172
            • 5,888 Posts
            Quote from: Firebird at Apr 10, 2011, 02:52 PM

            Hello,

            Is it possible to write an plain js filter for an extjs grid without sending queries to the db? I have a grid with several columns (title, description, ...) and want to implement an input field a user can use to search. I thought of something like a LIKE %word% using several columns.


            // changed title

            I don’t understand: How do you want to filter db-records without sending a query to the db?
            Adding an input-field for filtering the grid-result by sending a db-query is easy to implement into the grid if mean that.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 9710
              • 24 Posts
              Quote from: Bruno17 at Apr 12, 2011, 07:27 AM

              I don’t understand: How do you want to filter db-records without sending a query to the db?
              Adding an input-field for filtering the grid-result by sending a db-query is easy to implement into the grid if mean that.
              I wanted to filter the grid data client side via js. But I just realized that the grid does only store the data of the current "page". rolleyes
              So you are right: It’s not possible. :’(

              I will simply add an extra input field..
                • 17499 ☆ A M B ☆
                • 872 Posts
                It is possible, but you will have to load the entire store without the limit parameter on load (and of course on server side)
                //basically 
                store.load()
                


                Results can still be paginated on front end side with extjs (the memory print and load time will also be inpacted).
                Use the mode parameter from the plugin:


                mode : String
                Use ’remote’ for remote stores or ’local’ for local stores. If mode is local no data requests are sent to server the grid’s store is filtered instead (defaults to "remote")