PDA

View Full Version : PagingStore get data of actual view



eztam
23 Feb 2010, 11:56 PM
Hi,

I'm using a GridPanel with Ext.ux.data.PagingStore.

I also use a customized Ext.ux.form.SearchField (see code at the end of the post)

Now I want to be able to get the data of the actual view (including all pages!).

For better understanding a sample Grid:


---------------------
| Column 1 | Column 2 |
---------------------
| Value 1 | Value 2 |
| Value 3 | Value 4 |
---------------------

I want to get an Object like this:


var obj = {
headers: ['Column 1', 'Column 2'],
rows: [
[
['Value 1', 'Value 2'],
['Value 3', 'Value 4']
]
//further pages here...
]
}

This Object should show all data of the view (hidden fields and filtered excluded).

How can I do this?



------------------------------------------------------------------------
Customized SearchField:


Ext.override(Ext.ux.form.SearchField, {
enableKeyEvents: true,
initComponent : function(){
Ext.ux.form.SearchField.superclass.initComponent.call(this);
this.on('keyup', function(f, e){
this.onTrigger2Click();
if(e.getKey() == e.ESC)
this.onTrigger1Click();
}, this);
},
onTrigger2Click: function() {
var value = this.getRawValue();
var fields = [];
var items = this.store.fields.items;
if(Ext.isEmpty(value)) {
this.onTrigger1Click();
return false;
}
for (var i in items) {
if (items[i].filterable) {
fields.push({type:items[i].type, dataIndex: items[i].dataIndex});
}
}
this.store.filterBy(function(record,id) {
for (var i in fields) {
var reg = new RegExp(value, "i");
if(reg.test(record.data[fields[i].dataIndex]))
return true;
}
});
this.hasSearch = true;
this.triggers[0].show();
}
});