-
23 Nov 2010 5:18 AM #151Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
In that case you should be using:
Code:<link rel="stylesheet" type="text/css" href="ext/examples/ux/gridfilters/css/GridFilters.css" /> <link rel="stylesheet" type="text/css" href="ext/examples/ux/gridfilters/css/RangeMenu.css" /> <script type="text/javascript" src="ext/examples/ux/gridfilters/menu/RangeMenu.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/menu/ListMenu.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/GridFilters.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/Filter.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/StringFilter.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/DateFilter.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/ListFilter.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/NumericFilter.js"></script> <script type="text/javascript" src="ext/examples/ux/gridfilters/filter/BooleanFilter.js"></script>
-
23 Nov 2010 5:41 AM #152
Cheers Condor it didn't even click this was all in the examples directory. I'd added the file manually but seems things weren't right as once I copied your code over and put in the correct paths it worked perfectly.
-
23 Nov 2010 7:41 AM #153
how do I clear the fields of search?
using clearFilters(), it only cleans the headlines, but what was typed in the search still continues in the fields, how do I clear all fields of search?
grid.jpg
thanks
-
23 Nov 2010 11:47 AM #154
First I would like to thank you for your time and knowledge
Win 7 Ext JS 4.1.3 IE(6-9), FF17
-
23 Nov 2010 11:53 AM #155
-
25 Nov 2010 2:08 AM #156
Hi,
I've found a change Between Ext 3.1.1 GridFilters.js and Ext 3.3.0 GridFilters.js :
In function addFilters, line 575 has changed
And I was wondering if it was volumtary ?PHP Code:from : filter.type = filter.type || this.store.fields.get(dI).type;
to : filter.type = filter.type || this.store.fields.get(dI).type.type;
-
26 Nov 2010 1:10 AM #157
A question related to grid filtering: how to configure a remote data source with a store for list filter?
I've not understand this:
"If the data for the list is remote, use the {@link #store} config instead."
-
26 Nov 2010 1:24 AM #158
Hi,
first you have to configure a store for your filter:
ThenPHP Code:
var storeFilter = new Ext.data.JsonStore({
storeId: 'yourStoreId',
autoLoad: false,//or as you need it
proxy: new Ext.data.HttpProxy({
url: 'database.php'
}),
root: 'rows',
fields: [ 'id', 'text'] //it is important to have the fields named as 'id' and 'text'
});
In your grid load script you need to have something like this(here for PHP):PHP Code:
var gridFilter= new Ext.ux.grid.GridFilters({
menuFilterText: 'Filter',
filters:[{type: 'string', dataIndex: 'NAME'}
,{type: 'list', dataIndex:'STATE', store:storeFilter, phpMode:true} //your case
]});
PHP Code:
<?php
$where = " 0 = 0 ";
if (is_array($filter)) {
for ($i=0;$i<count($filter);$i++){
switch($filter[$i]['data']['type']){
case 'string' : $qs .= " AND ".$filter[$i]['field']." LIKE '%".$filter[$i]['data']['value']."%'"; break;
case 'list' :
if (strstr($filter[$i]['data']['value'],',')){
$fi = explode(',',$filter[$i]['data']['value']);
for ($q=0;$q<count($fi);$q++){
$fi[$q] = "'".$fi[$q]."'";
}
$filter[$i]['data']['value'] = implode(',',$fi);
$qs .= " AND ".$filter[$i]['field']." IN (".$filter[$i]['data']['value'].")";
}else{
$qs .= " AND ".$filter[$i]['field']." = '".$filter[$i]['data']['value']."'";
}
Break;
case 'boolean' : $qs .= " AND ".$filter[$i]['field']." = ".($filter[$i]['data']['value']); break;
case 'numeric' :
switch ($filter[$i]['data']['comparison']) {
case 'ne' : $qs .= " AND ".$filter[$i]['field']." != ".$filter[$i]['data']['value']; break;
case 'eq' : $qs .= " AND ".$filter[$i]['field']." = ".$filter[$i]['data']['value']; break;
case 'lt' : $qs .= " AND ".$filter[$i]['field']." < ".$filter[$i]['data']['value']; break;
case 'gt' : $qs .= " AND ".$filter[$i]['field']." > ".$filter[$i]['data']['value']; break;
}
break;
case 'date' :
switch ($filter[$i]['data']['comparison']) {
case 'ne' : $qs .= " AND ".$filter[$i]['field']." != '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; break;
case 'eq' : $qs .= " AND ".$filter[$i]['field']." = '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; break;
case 'lt' : $qs .= " AND ".$filter[$i]['field']." < '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; break;
case 'gt' : $qs .= " AND ".$filter[$i]['field']." > '".date('Y-m-d',strtotime($filter[$i]['data']['value']))."'"; break;
}
Break;
}
}
$where .= $qs;
}First I would like to thank you for your time and knowledge
Win 7 Ext JS 4.1.3 IE(6-9), FF17
-
26 Nov 2010 1:44 AM #159
Ok, great. I'll test it.
One note, this: labelField: 'name' override the name 'text' for display name of data in my store, it's true? (I've a store already and I want to reuse it)
-
26 Nov 2010 1:55 AM #160
STATE ist the dataIndex config option of your Column which is bound to your field name of the store record (grid store), so the filter is just bound to it too. Your filter send to your grid load script STATE. Play a little bit with firebug and you'll see exactly how the filter parameters are sent.
First I would like to thank you for your time and knowledge
Win 7 Ext JS 4.1.3 IE(6-9), FF17


Reply With Quote