-
7 Aug 2011 9:38 PM #1001
When using Ivanblanc's 4.0 port, I get "b is undefined" error
When using Ivanblanc's 4.0 port, I get "b is undefined" error
Ivanblanc, thank you very much for posting a version of the search plugin for 4.0.
When I view my grid, the search box is visible. However, when I enter a search term and hit enter, nothing happens.
I looked at Firebug and discovered that there was an error saying b is undefined. It involves the Extjs-all.js file, line 7, which is here: (function(){var e=this,a=Object.protot...ate("Ext.XTemplate",j,g)}return j}});
I have selected the "local" option in my searching.js file, just to keep things simple for now.
the only other strange thing I've noticed is that searching.js file has a line reading "this.grid = this.view.up('gridpanel');". If I change the gridpanel to fit my grid name, it also creates an error saying that it is undefined.
Any ideas from anyone?
Here is an except from my code:
Code:Ext.define('User', { extend: 'Ext.data.Model', fields: ['recordnumber', 'itemprice']}); Ext.define('UsersGrid', { extend: 'Ext.grid.Panel', initComponent: function() { var userStore = Ext.create('Ext.data.Store', { autoLoad: true, model: 'User', proxy: { type: 'ajax', api: { read: 'extjs/database.php?task=LISTING', }, reader: { type: 'json', root: 'results', }, }, }); Ext.apply(this, { viewConfig:{ forceFit: false, stripeRows: true, trackOver: true }, store: userStore, features: [searching], columns: [{ text: 'Record', width: 45, sortable: true, hideable: true, dataIndex: 'recordnumber' }, { text: 'Item Price', renderer: 'usMoney', width: 55, sortable: true, hideable: true, dataIndex: 'itemprice'}], // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: userStore, displayInfo: true, displayMsg: 'Displaying topics {0} - {1} of {2}', emptyMsg: "No topics to display", }), }); UsersGrid.superclass.initComponent.apply(this,arguments); } }); Ext.onReady(function() { var grid1 = Ext.create('UsersGrid', { renderTo: 'place-for-grid', height: 300, width: 600, title: 'Database' });
-
8 Aug 2011 6:00 AM #1002
@ preichow
I have put together an example based on to Ext 4 grid examples.
First one being the Basic Array grid to show local searching and the second one is the Infinite Grid example which uses the remote searching.
There is one thing I did change that is not too intuitive because I give no feed back when the error is made. When the actual search is executed if its mode=local then I do nothing special, but if its remote I check to make sure you have a Server proxy configured before I proceed with the search, if you don't then the plugin does nothing.
You will not see the Infinite Grid actually filter because obviously I can't access the back end code of sencha, but you will see the grid load screen come up and the store load request sent with the proper parameters to handle the remote searching.
Should be able to just drop and run this code... just change the path of "Searching.js" to reflect your server.
As for theCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.2a/resources/css/ext-all.css"> <script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.2a/ext-all-debug.js"></script> <script type="text/javascript" src="/public/ext/ux/4.0/grid/feature/Searching.js"></script> </head> <body> <script type="text/javascript"> Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*', 'Ext.grid.PagingScroller' ]); Ext.onReady(function() { Ext.QuickTips.init(); // setup the state provider, all state information will be saved to a cookie Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider')); // sample static data for the store var myData = [ ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'], ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'], ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'], ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'], ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'], ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'], ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'], ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'], ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'], ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'], ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'], ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'], ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'], ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'], ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'], ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'], ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'], ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'], ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'], ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'], ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'], ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'], ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'], ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'], ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'], ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'], ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'], ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'], ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am'] ]; /** * Custom function used for column renderer * @param {Object} val */ function change(val) { if (val > 0) { return '<span style="color:green;">' + val + '</span>'; } else if (val < 0) { return '<span style="color:red;">' + val + '</span>'; } return val; } /** * Custom function used for column renderer * @param {Object} val */ function pctChange(val) { if (val > 0) { return '<span style="color:green;">' + val + '%</span>'; } else if (val < 0) { return '<span style="color:red;">' + val + '%</span>'; } return val; } // create the data store var store = Ext.create('Ext.data.ArrayStore', { fields: [ {name: 'company'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'} ], data: myData }); var searching = { ftype: 'searching', mode: 'local' }; // create the Grid var grid = Ext.create('Ext.grid.Panel', { store: store, features: [searching], stateful: true, stateId: 'stateGrid', columns: [ { text : 'Company', flex : 1, sortable : false, dataIndex: 'company' }, { text : 'Price', width : 75, sortable : true, renderer : 'usMoney', dataIndex: 'price' }, { text : 'Change', width : 75, sortable : true, renderer : change, dataIndex: 'change' }, { text : '% Change', width : 75, sortable : true, renderer : pctChange, dataIndex: 'pctChange' }, { text : 'Last Updated', width : 85, sortable : true, renderer : Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange' } ], height: 350, width: 600, title: 'Array Grid', renderTo: 'basic', viewConfig: { stripeRows: true } }); //**************************************************************************** // Infinate Grid example //**************************************************************************** Ext.define('ForumThread', { extend: 'Ext.data.Model', fields: [ 'title', 'forumtitle', 'forumid', 'author', {name: 'replycount', type: 'int'}, {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'}, 'lastposter', 'excerpt', 'threadid' ], idProperty: 'threadid' }); // create the Data Store var store = Ext.create('Ext.data.Store', { id: 'store', pageSize: 200, model: 'ForumThread', remoteSort: true, // allow the grid to interact with the paging scroller by buffering buffered: true, proxy: { // load using script tags for cross domain, if the data in on the same domain as // this page, an HttpProxy would be better type: 'jsonp', url: 'http://www.sencha.com/forum/remote_topics/index.php', extraParams: { total: 50000 }, reader: { root: 'topics', totalProperty: 'totalCount' }, // sends single sort as multi parameter simpleSortMode: true }, sorters: [{ property: 'lastpost', direction: 'DESC' }] }); function renderTopic(value, p, record) { return Ext.String.format( '<a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a>', value, record.data.forumtitle, record.getId(), record.data.forumid ); } var searching = { ftype: 'searching', mode: 'remote', position: 'top' }; var grid = Ext.create('Ext.grid.Panel', { width: 700, height: 500, title: 'ExtJS.com - Browse Forums', store: store, features: [searching], verticalScrollerType: 'paginggridscroller', loadMask: true, disableSelection: true, invalidateScrollerOnRefresh: false, viewConfig: { trackOver: false }, // grid columns columns:[{ xtype: 'rownumberer', width: 50, sortable: false },{ // id assigned so we can apply custom css (e.g. .x-grid-cell-topic b { color:#333 }) // TODO: This poses an issue in subclasses of Grid now because Headers are now Components // therefore the id will be registered in the ComponentManager and conflict. Need a way to // add additional CSS classes to the rendered cells. id: 'topic', text: "Topic", dataIndex: 'title', flex: 1, renderer: renderTopic, sortable: false },{ text: "Author", dataIndex: 'author', width: 100, hidden: true, sortable: true },{ text: "Replies", dataIndex: 'replycount', align: 'center', width: 70, sortable: false },{ id: 'last', text: "Last Post", dataIndex: 'lastpost', width: 130, renderer: Ext.util.Format.dateRenderer('n/j/Y g:i A'), sortable: true }], renderTo: Ext.getBody() }); // trigger the data store load store.guaranteeRange(0, 199); }); </script> <div id="basic"></div> <br /> <div id="topic-grid"></div> </body> </html>
I had a hard time figuring out where to run the onRender method Saki was using to add the searching toolbar. Other grid features from the API used attachEvents function to initialize stuff for the feature, so that's where I put mine. At that point this.grid was not initiated yet for some reason, but this.view was. So i ran a this.view.up to get me the grid so I could attach the render listener. It is probably kind of funky but it worked so I left it alone.Code:this.grid = this.view.up('gridpanel');
-
9 Aug 2011 2:34 AM #1003
Hi,
Is the plugin works with Ext.ux.maximgb.treegrid.GridPanel ??
ty
-
16 Aug 2011 4:51 AM #1004
-
3 Sep 2011 2:36 AM #1005
Hi ivanleblanc,
Thank you so much for porting this excellent plugin to Ext4.
It works perfectly for me, straight out of the box
I particularly like the way it will search after a short delay, without having to hit "Enter". I'm not sure if the original plugin was able to be configured to do this, but it was always necessary for me to hit "Enter" before the new data would show up. Btw I'm using remote stores.
This is awesome, thanks again
-
11 Sep 2011 1:01 AM #1006
a bug?
a bug?
Thanks Saki & ivanleblanc, this is wonderful. I think I found a bug though.
If I have tabpanel with 2 tabs, each tab contains a searchable grid. Then first grid will not have the search box, while the second grid will have 2 search boxes.
I'm attaching a screenshot.
search_bug.jpg
Hope this will be fixed soon
Thanks!
-
20 Apr 2012 5:55 AM #1007
Search feature for Grid Panel
Search feature for Grid Panel
Can you please tell from the scratch, how to use this Grid Search Plugin using Asp.Net MVC.
i was able to load gridpanel successfully with paging and sorting features..but i need search feature also in my gridpanel.
i have googled a lot for solution. but i got nothing...can you please help me out ...
-
23 Apr 2012 5:42 AM #1008
@ panpur
Can you post some code, may be how you have it laid out or something.
Here's a quick example I made using the grid-array.js example form docs and it seems to work fine.
I am using the Ext 4.1 rc3 in this example...
Code:<html> <head> <title>Grid Search</title> <link rel="stylesheet" type="text/css" href="../../../public/ext/4.1.0-rc3/resources/css/ext-all.css"> <script type="text/javascript" src="../../../public/ext/4.1.0-rc3/ext-all-debug.js"></script> <script type="text/javascript" src="../../../public/ext/ux/4.1/grid/feature/Searching.js"></script> <script type="text/javascript"> Ext.require([ 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.state.*' ]); Ext.define('Company', { extend: 'Ext.data.Model', fields: [ {name: 'company'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'} ], idProperty: 'company' }); Ext.onReady(function() { Ext.QuickTips.init(); // setup the state provider, all state information will be saved to a cookie Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider')); // sample static data for the store var myData = [ ['3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'], ['Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'], ['Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'], ['American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'], ['American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'], ['AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'], ['Boeing Co.', 75.43, 0.53, 0.71, '9/1 12:00am'], ['Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'], ['Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'], ['E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'], ['Exxon Mobil Corp', 68.1, -0.43, -0.64, '9/1 12:00am'], ['General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'], ['General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'], ['Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'], ['Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'], ['Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'], ['International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'], ['Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'], ['JP Morgan & Chase & Co', 45.73, 0.07, 0.15, '9/1 12:00am'], ['McDonald\'s Corporation', 36.76, 0.86, 2.40, '9/1 12:00am'], ['Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'], ['Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'], ['Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'], ['The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'], ['The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'], ['The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'], ['United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'], ['Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'], ['Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am'] ]; /** * Custom function used for column renderer * @param {Object} val */ function change(val) { if (val > 0) { return '<span style="color:green;">' + val + '</span>'; } else if (val < 0) { return '<span style="color:red;">' + val + '</span>'; } return val; } /** * Custom function used for column renderer * @param {Object} val */ function pctChange(val) { if (val > 0) { return '<span style="color:green;">' + val + '%</span>'; } else if (val < 0) { return '<span style="color:red;">' + val + '%</span>'; } return val; } // create the data store var store1 = Ext.create('Ext.data.ArrayStore', { model: 'Company', data: myData }); var store2 = Ext.create('Ext.data.ArrayStore', { model: 'Company', data: myData }); // create Grid Searching feature var searching = { ftype: 'searching', minChars: 2, position: 'top', mode: 'local' }; // create the Grid var grid1 = Ext.create('Ext.grid.Panel', { store: store1, stateful: true, collapsible: true, multiSelect: true, stateId: 'stateGrid', features: [searching], columns: [ { text : 'Company', flex : 1, sortable : false, dataIndex: 'company' }, { text : 'Price', width : 75, sortable : true, renderer : 'usMoney', dataIndex: 'price' }, { text : 'Change', width : 75, sortable : true, renderer : change, dataIndex: 'change' }, { text : '% Change', width : 75, sortable : true, renderer : pctChange, dataIndex: 'pctChange' }, { text : 'Last Updated', width : 85, sortable : true, renderer : Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange' } ], height: 350, width: 600, title: 'Array Grid', //renderTo: Ext.getBody(), viewConfig: { stripeRows: true, enableTextSelection: true } }); var grid2 = Ext.create('Ext.grid.Panel', { store: store2, stateful: true, collapsible: true, multiSelect: true, stateId: 'stateGrid', tbar: ['->'], features: [searching], columns: [ { text : 'Company', flex : 1, sortable : false, dataIndex: 'company' }, { text : 'Price', width : 75, sortable : true, renderer : 'usMoney', dataIndex: 'price' }, { text : 'Change', width : 75, sortable : true, renderer : change, dataIndex: 'change' }, { text : '% Change', width : 75, sortable : true, renderer : pctChange, dataIndex: 'pctChange' }, { text : 'Last Updated', width : 85, sortable : true, renderer : Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange' } ], height: 350, width: 600, title: 'Array Grid', //renderTo: Ext.getBody(), viewConfig: { stripeRows: true, enableTextSelection: true } }); var tabpanel = Ext.create('Ext.tab.Panel', { renderTo: Ext.getBody(), items: [ grid1, grid2 ] }); }); </script> </head> <body> </body> </html>
-
23 Apr 2012 7:04 AM #1009
Can you please tell me how to implement the above grid search dynamically using asp.net MVC 3.
Grid should have sorting, paging and searching features.
Thanks in advance
-
23 Apr 2012 8:04 AM #1010


Reply With Quote