Custom function call after Extjs 4 grid sort - extjs

I have an Extjs 4 grid with sort capability. i want to call a custum function after each time user presses sort button.
In my custom function i want to navigate to the first page of my grid (my grid uses pagination and it takes advantage of server-side sort) i think i must use store.loadPage(1) in my custom function (correct me if I'm wrong)
where should i put my custom function?
This is my Ext.OnReady() function:
Ext.onReady(function() {
Ext.tip.QuickTipManager.init();
var url = {
local: 'grid-filter.json', // static data file
remote: 'grid-filter.php'
};
var paging = true;
var encode = false;
var local = false;
Ext.define('UserDirectoryDataModel', {
extend : 'Ext.data.Model',
fields : [ 'uname', 'fname', 'lname', 'postcode', 'mail', {
name : 'pass'
}, 'hasAccess', 'isActive', 'lastVisit' , 'deleteUser'],
idProperty : 'uname'
});
var itemsPerPage = 20;
var store = Ext.create('Ext.data.Store', {
pageSize : itemsPerPage,
autoLoad: false,
local: false,
autoDestroy: true,
model : 'UserDirectoryDataModel',
autoSync : true,
sortOnLoad : true,
remoteSort:true,
sorters : {
property : 'uname',
direction : 'ASC'
},
listeners: {
beforeload: function(){
store.loadPage(1);
}
},
proxy : {
type : 'ajax',
url: (local ? url.local : url.remote),
api : {
read : 'read.php',
update : 'update.php'
},
reader : {
type : 'json',
root : 'users',
successProperty : 'success',
totalProperty : 'totalCount'
},
writer : {
type : 'json',
writeAllFields : true,
encode : false,
root : 'users'
},
afterRequest : function(request, success) {
if (request.action == 'update') {
if (success) {
Ext.MessageBox.alert('alert',
'data updated!');
}
}
}
}
});
store.load({
params:{
start:0,
limit: itemsPerPage
}
});
var filters = {
ftype: 'filters',
encode: encode, // json encode the filter query
local: local, // defaults to false (remote filtering)
filters: [
{
}
]
};
var createColumns = function (finish, start) {
var columns = [ {
text : "username",
dataIndex : 'uname',
width : 150,
filterable: true,
align : 'right'
}, {
text : "name",
dataIndex : 'fname',
width : 150,
align : 'right',
hidden : false,
sortable : true,
filterable: true,
editor : {
xtype : 'textfield',
allowBlank : false
}
}, {
text : "last name",
dataIndex : 'lname',
width : 150,
align : 'right',
sortable : true,
filterable: true,
editor : {
xtype : 'textfield',
allowBlank : false
}
}, {
text : "PostalCode",
dataIndex : 'postcode',
width : 110,
align : 'right',
sortable : true,
filterable: true,
editor : {
xtype : 'textfield',
allowBlank : false
}
}, {
text : "email",
dataIndex : 'mail',
width : 200,
align : 'right',
sortable : true,
filterable: true,
editor : {
xtype : 'textfield',
allowBlank : false
}
}, {
text : "password",
width : 150,
align : 'right',
sortable : false,
filterable: true,
hidden : true,
dataIndex : 'pass',
editor : {
xtype : 'textfield',
inputType : 'password',
allowBlank : true
}
}, {
text : "access to system",
dataIndex : 'hasAccess',
renderer:function(value){
if(value[0]=="1"){
return "has";
}else{
return "doens't have";
}
},
width : 100,
align : 'center',
sortable : false,
filterable: false
}, {
text : "active",
dataIndex : 'isActive',
renderer:function(value){
if(value==null)
return;
if(value[0]=="1"){
return "no";
}else if(value[0]=="0"){
return "yes";
}else if(value[0]=="2"){
return "Not in portal!";
}
},
width : 100,
align : 'center',
sortable : false,
filterable: false
}, {
text : "last visit",
dataIndex : 'lastVisit',
width : 120,
hidden : true,
align : 'right',
sortable : true,
filterable: true
}, {
text : " ",
dataIndex : 'uname',
renderer:function(value){
return "delete";
},
width : 120,
hidden : true,
align : 'right'
} ];
return columns.slice(start || 0, finish);
};
var pluginExpanded = true;
var grid = Ext.create('Ext.grid.Panel', {
border: false,
width : 1200,
height : 620,
title : '',
store: store,
disableSelection : false,
seltype : 'rowmodel',
loadMask : true,
viewConfig : {
id : 'gv',
trackOver : false,
stripeRows : false,
plugins : [ {
ptype : 'preview',
bodyField : 'excerpt',
expanded : true,
pluginId : 'preview'
} ]
},
columns: createColumns(),
features: [filters],
dockedItems: [Ext.create('Ext.toolbar.Paging', {
dock: 'bottom',
store: store
})],
plugins : [ Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit : 2
}) ],
renderTo : 'userdatagrid'
});
grid.child('pagingtoolbar').add([
{
text: 'show filters',
handler: function () {
var data = Ext.encode(grid.filters.getFilterData());
Ext.Msg.alert('show filters',data);
}
},{
text: 'delete filters',
handler: function () {
grid.filters.clearFilters();
}
}
]);
store.loadPage(1);
});

Or you could use this:
grid.on('sortchange', function() {
grid.getStore().loadPage(1);
});

Forget everything I wrote:
Server Side sorting in an ExtJS GridPanel
You should put your custom function in the grid event: sortchange.
I just re-read your question - I thought you have infinite paging.
If your sort is done server side, then yes, you need to call loadPage(1).
You also need to send the sort parameters.
listeners: {
sortchange: function(){
var grid = Ext.ComponentQuery.query('my-grid-alias')[0];
grid.getStore().loadPage(1);
}
}
I hope this helps.

I just put a loadPage(1) in the sortchange event, but it made twice server request(grid made the first one with sort parameters automatically), how could it be only once?

I figure out one solution, I set "remoteSort:false" in store and
"sortchange: {fn:function(){
var time = (new Date()).getTime()/1000;
// after {remoteSort:false} is set, sortchange event will be fired twice when column header is clicked, so I had to set a parameter for time record
if('undefined' == typeof(this.last_sort_time) || this.last_sort_time+1 < time){
this.getStore().loadPage(1);
this.last_sort_time = time;
}
}, scope:this}"
in grid.
But it not works fine, because the received data was reordered by the grid before displayed on it
At last, I solve the problem in this way:
Ext.override(Ext.grid.column.Column, {
doSort:function(){
var ds = this.up('tablepanel').store;
ds.currentPage = 1;
this.callParent(arguments);
}
});
And it works perfectly so far

sortchange event fires after request is send to the server. For solution look here
http://www.sencha.com/forum/showthread.php?145779-Reset-page-for-paginator-on-sort-change

Related

ExtJs two or more grids on same page

I'm new with ExtJS.
I have two grids on a same page. First grid has 3 columns. Second only one. Problem is that when second is rendered, it is overwriting properties of the first grid.
For example when I try to edit row in first grid, it takes the width on the row from second grid.
var $booleanArray = [
['denied', 'Denied'],
['allowed', 'Allowed']
];
var myPageSize = 10;
Ext.Loader.setConfig({ enabled: true });
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*'
]);
Ext.onReady(function () {
Ext.define('CharacteristicModel', {
extend: 'Ext.data.Model',
fields: [ {name: 'name'}, {name: 'value'}, {name: 'order'} ],
validations: [
{
type : 'length',
field: 'name',
min : 1
}
]
});
var characteristicsStore = new Ext.data.Store({
proxy : {
model : 'CharacteristicModel',
type : 'rest',
api : {
read : admin_path + '/getCharacteristics/1/',
create : admin_path + '/saveCharacteristics/1/',
update : admin_path + '/saveCharacteristics/1/',
destroy: admin_path + '/destroyCharacteristic/1/'
},
reader : {
type : 'json',
root : 'data',
totalProperty: 'total_count'
},
writer : {
type: 'json',
root: 'data'
},
buffered: true
},
listeners: {
read : function (response) {
},
load : function (store) {
},
write: function (store, operation) {
store.load();
}
},
pageSize : myPageSize,
autoLoad : { start: 0, limit: myPageSize },
autoSync : true
});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');
var characteristicsGrid = new Ext.grid.GridPanel({
id : 'characteristicsGrid',
renderTo : 'characteristics_grid_div_1',
store : characteristicsStore,
width : 480,
stateful : true,
stateId : 'characteristicsGrid',
title : 'Grid "1"',
iconCls : 'icon-user',
listeners : {
itemdblclick: function (dv, row, item, index, e) {
dv.refresh();
dv.getGridColumns()[0].setEditor({
disabled: true,
editable: false
});
if (row.data.id == 6 || row.data.id == 7) {
dv.getGridColumns()[1].setEditor({
xtype : 'combo',
store : new Ext.data.ArrayStore({
fields: ['abbr', 'action'],
data : $booleanArray
}),
displayField : 'action',
valueField : 'abbr',
mode : 'local',
typeAhead : false,
triggerAction: 'all',
lazyRender : true,
emptyText : 'Select action'
});
}
else if (row.data.id == 8 || row.data.id == 11) {
dv.getGridColumns()[1].setEditor({
disabled: true,
editable: false
});
}
else {
dv.getGridColumns()[1].setEditor({
xtype: 'textfield'
});
}
}
},
columns : [
{
id : 'name',
text : 'Account characteristic',
sortable : false,
width : 340,
fixed : true,
dataIndex: 'name'
},
{
id : 'value',
text : 'Value',
sortable : false,
dataIndex: 'value',
width : 70,
fixed : true,
editor : {
xtype: 'textfield'
},
renderer : function (value, field) {
if (field.record.data.id == 6 || field.record.data.id == 7) {
if ($booleanArray[0][0] != value) {
value = $booleanArray[1][1];
}
else {
value = $booleanArray[0][1];
}
}
return value;
}
},
{
id : 'order',
text : 'Order',
sortable : false,
dataIndex: 'order',
width : 70,
fixed : true,
editor : {
xtype: 'textfield'
},
renderer : function (value, field) {
return value;
}
}
],
bbar : Ext.create('Ext.PagingToolbar', {
store : characteristicsStore,
displayInfo: true,
pageSize : myPageSize,
displayMsg : 'Show {0} - {1} из {2}',
emptyMsg : "0 rows"
}),
dockedItems: [
{
xtype: 'toolbar',
items: [
{
text : 'Add',
iconCls: 'icon-add',
handler: function () {
var grid_colums = rowEditing.cmp.getSelectionModel().view.getGridColumns();
grid_colums[0].setEditor({
xtype : 'combo',
store : new Ext.data.ArrayStore({
fields: ['id', 'name'],
data : $characteristics
}),
displayField : 'name',
valueField : 'id',
mode : 'local',
typeAhead : false,
triggerAction: 'all',
lazyRender : true,
emptyText : 'Select action'
});
grid_colums[1].setEditor({
xtype: 'textfield'
});
// empty record
//characteristicsStore.autoSync = false;
characteristicsStore.insert(0, new CharacteristicModel());
rowEditing.startEdit(0, 0);
//characteristicsStore.autoSync = true;
}
},
'-',
{
itemId : 'delete',
text : 'Delete',
iconCls : 'icon-delete',
disabled: true,
handler : function () {
var selection = characteristicsGrid.getView().getSelectionModel().getSelection()[0];
if (selection) {
characteristicsStore.remove(selection);
}
}
}
]
}
],
plugins : [rowEditing]
});
characteristicsGrid.getSelectionModel().on('selectionchange', function (selModel, selections) {
characteristicsGrid.down('#delete').setDisabled(selections.length === 0);
});
});
Ext.onReady(function () {
Ext.define('AdvantagesModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'name'}
]
});
// setup the state provider, all state information will be saved to a cookie
//Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
var advantagesStore = new Ext.data.Store({
idProperty: 'AdvantagesModel',
proxy : {
model : 'AdvantagesModel',
type : 'rest',
api : {
read : admin_path + '/getAdvantages/1/',
create : admin_path + '/saveAdvantages/1/',
destroy: admin_path + '/destroyAdvantages/1/'
},
reader : {
type : 'json',
root : 'data',
totalProperty: 'totalCount'
},
writer : {
type: 'json',
root: 'data'
},
buffered: true
},
listeners: {
read : function (response) {
},
load : function (store) {
},
write: function (store, operation) {
store.load();
}
},
pageSize : myPageSize,
autoLoad : { start: 0, limit: myPageSize },
autoSync : true
});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');
var advantagesGrid = new Ext.grid.GridPanel({
id : 'advantagesGrid',
renderTo : 'advantages_grid_div_1',
store : advantagesStore,
width : 482,
height : 355,
stateful : true,
stateId : 'advantagesGrid',
title : 'Grid 2',
iconCls : 'icon-user',
listeners : {
beforeedit: function (dv, row, item) {
//advantagesGrid.getView().refresh();
if (row.record.raw)
{
return false;
}
}
},
columns : [
{
id : 'name',
text : 'Advantages',
sortable : false,
dataIndex: 'name',
width : 480
}
],
bbar : Ext.create('Ext.PagingToolbar', {
store : advantagesStore,
displayInfo: true,
pageSize : myPageSize,
displayMsg : 'Show {0} - {1} из {2}',
emptyMsg : "0 rows"
}),
dockedItems: [
{
xtype: 'toolbar',
items: [
{
text : 'Add',
iconCls: 'icon-add',
handler: function () {
var grid_colums = rowEditing.cmp.getSelectionModel().view.getGridColumns();
grid_colums[0].setEditor({
xtype : 'combo',
store : new Ext.data.ArrayStore({
fields: ['id', 'name'],
data : $advantages
}),
displayField : 'name',
valueField : 'id',
mode : 'local',
typeAhead : false,
triggerAction: 'all',
lazyRender : true,
emptyText : 'Select action'
});
// empty record
advantagesStore.autoSync = false;
advantagesStore.insert(0, new AdvantagesModel());
rowEditing.startEdit(0, 0);
advantagesStore.autoSync = true;
}
},
'-',
{
itemId : 'delete',
text : 'Delete',
iconCls : 'icon-delete',
disabled: true,
handler : function () {
var selection = advantagesGrid.getView().getSelectionModel().getSelection()[0];
if (selection) {
advantagesStore.remove(selection);
}
}
}
]
}
],
plugins : [rowEditing]
});
advantagesGrid.getSelectionModel().on('selectionchange', function (selModel, selections) {
advantagesGrid.down('#delete').setDisabled(selections.length === 0);
});
});
The alternative to having your two grid id columns identified differently is to have two different instances/objects of the Ext.grid.plugin.RowEditing class if you have two editable grids on the same page. Many times it's important to have the same id.
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing');
var rowEditing2 = Ext.create('Ext.grid.plugin.RowEditing');
plugins : [rowEditing]
plugins : [rowEditing2]
found the problem.
columns : [
{
id : 'name',
columns ids must be different, even if they are in diferent grids

Grid doesn't change even after reloading store while filtering

I want a grid that will change or reload after delete any row and retrieve those rows that have same member id. For this, I add filter. Again I callback store with filter after delete any row. My store filter well but grid couldn't display it......It holds the previous display......
Ext.define('${pkgName}.v02x001001.SV02X00100101' , {
extend : 'Ext.grid.Panel',
alias : 'widget.sv02x00100101',
id : 'sv02x00100101',
border : true,
modal : true,
height : 300,
width : 455,
viewConfig: {
stripeRows : true,
forceFit : true,
emptyText : 'No Records to display',
listeners : {
viewready : function(v) {
var store = Ext.data.StoreManager.get('S02X001001');
store = !store ? Ext.create("S02X001001") : store;
var value = Ext.getCmp('member-sv02x00100104').getValue(),
filters = new Array();
store.clearFilter();
store.filter('member', value);
filters.push({
property : 'member',
value : value
});
store.loadPage(1, {
filters : filters
});
}
}
},
initComponent: function() {
this.store = 'S02X001001';
this.tbar= Ext.create('Ext.ux.StatusBar', {
topBorder : false,
statusAlign : 'right',
items : [{
xtype :'button',
text : 'ADD',
icon : "${resource(dir: 'images', file: 'ADD01003.png')}",
listeners : {
click : this.onNewAddress
}
},'-']
});
this.columns = [
{
text : 'Address Line 1',
dataIndex : 'addressline1',
sortable : false,
flex : 1
},{
text : 'Address Line 2',
dataIndex : 'addressline2',
sortable : false,
width : 170
},{
menuDisabled : true,
sortable : false,
id : 'deletee',
xtype : 'actioncolumn',
width : 22,
items : [{
icon : "${resource(dir: 'images', file: 'DEL01005.png')}",
tooltip : 'Delete This?',
scope : this,
handler : function(grid, rowIdx, colIdx) {
var record = grid.getStore().getAt(rowIdx);
var conId = record.data.id
this.onDeleteClick(conId);
}
}]
}];
this.callParent(arguments);
},
onNewAddress: function(btn, e, eOpts){
var view=Ext.widget('sv02x00100102');
view.show();
var a = Ext.getCmp('member-sv02x00100104').getValue();
Ext.getCmp('member-sv02x00100102').setValue(a);
},
onDeleteClick:function(conId){
Ext.MessageBox.show({
title : 'Delete',
msg : 'Really want to delete ?',
icon : Ext.Msg.WARNING,
buttons : Ext.MessageBox.YESNO,
buttonText :{
yes: "Delete",
no : "No"
},
scope : this,
animateTarget : 'deletee',
fn: function(btn, dbQty){
if(btn == 'yes'){
var registration = Ext.create('${appName}.model.M02X001001',{
id : conId
});
var store = this.getStore();
registration.destroy({
scope : this,
success : function(model, operation) {
if(model != null){
var store = Ext.data.StoreManager.get('S02X001001');
store = !store ? Ext.create("S02X001001") : store;
var value = Ext.getCmp('member-sv02x00100104').getValue(),
filters = new Array();
store.clearFilter();
store.filter('member', value);
filters.push({
property : 'member',
value : value
});
store.loadPage(1, {
filters : filters
});
}
},
failure: function(){
console.log('Unable to delete');
}
});
}
}
});
}
});
How it possible to retrieve rest of the relative rows ........
Here is my Store ..........
Ext.define('${pkgName}.S02X001001', {
extend : 'Ext.data.Store',
model : '${appName}.model.M02X001001',
idProperty: 'id',
autoLoad : true,
autoSync : true,
filterParam: 'query',
remoteSort: true,
proxy : {
type : 'ajax',
noCache : false,
limitParam: 'limit',
startParam: 'start',
url : '${createLink(controller:'C02x001001', action: 'store')}',
reader:{
type : 'json',
root : 'data',
totalProperty : 'total',
successProperty : 'success',
messageProperty : 'message',
implicitIncludes: true
},
simpleSortMode : true
},
sorters: [{
property: 'id',
direction: 'asc'
}]
});
it should be refresh the grid view in automatic,
but you can refresh the view by manual way :
use method getView().refresh();
try:
Ext.getCmp('sv02x00100101').getView().refresh();

extJS how to POST parameters through button?

I have this code. If i click on button my form parameters are inserting into database. How i can do it?? what i should write there?
And if i click on reset form, my window closing. Please help! Thank you!
var AddQuestion = new Ext.Button({
method : 'POST',
url : '/questions/create',
tooltip : 'Add Question',
icon : '/images/icons/silk/add.png',
iconCls : 'add',
style : 'margin-right: 60px;float:right;',
handler : function() {
new Ext.Window({
title : 'Add Question',
width : 700,
height : 800,
bodyStyle : 'padding: 10px',
layout : 'form',
modal : true,
closable : true,
resizable : false,
draggable : false,
autowidth : true,
items :[
{
fieldLabel : 'Question',
name : 'question[text]',
xtype : 'htmleditor',
enableFont : false,
enableFormat : false,
enableFontSize : false,
enableLists : false,
enableAlignments: false,
enableFont : false,
enableColors : false,
height : 160,
width : 560
},
{
name :'form_type',
fieldLabel :'Form Type',
xtype :'combo',
triggerAction :'all',
mode :'local',
editable : false,
allowBlank : false,
emptyText :'You should Choose any...',
store :new Ext.data.SimpleStore({
fields :['mode', 'name'],
data :[
['1', 'TextArea Question'],
['2', 'Scale Question'],
['3', 'TextArea + Scale Question']
]
}),
displayField :'name',
valueField :'mode',
hiddenName :'form_type'
},
{
xtype : 'itemselector',
name : 'selected_respondents',
imagePath : '../ux/images/',
bodyStyle : 'background:#DFE8F6',
multiselects: [{
legend : 'All Respondents',
width : 270,
height : 350,
store : st,
displayField : 'email',
valueField : 'id',
hiddenName : 'email'
},{
legend : 'Selected Respondents',
width : 270,
height : 350,
store : st2,
displayField : 'email',
valueField : 'id',
hiddenName : 'email'
}]
},
{
fieldLabel :'To do',
xtype : 'button',
text : 'Refresh respondents ↑',
height : 30,
icon : '/images/icons/silk/arrow_refresh_small.png',
width : 180,
handler: function(){
if((who_is_admin == '1') || (who_is_admin == '0')){
if (st2.getCount() == 0){
st.reload();
}else
{
Ext.Msg.show({
title : 'Message for You',
msg : "You should left <i>'Selected Respondents'</i> field empty to <b>refresh</b> some changes!",
modal : true,
Height : 200,
closable : true,
resizable : false,
draggable : false,
Width : 300,
buttons : Ext.Msg.OK
});
}
}
}
},
{
xtype : 'checkbox',
boxLabel : 'Make Question Active',
inputValue : '1',
name : 'is_active',
hiddenName : 'is_active',
checked : true
},
],
buttons: [{
text: 'Reset Form',
handler: function(){
}
},{
text: 'Submit Form',
handler: function(){
}
}
}] // button end
}).show(); //show window
}
});
You can do this by sending AJAX request as soon as user clicks on button.
For eg in your case handler for 'Submit Form' button should look like
Ext.Ajax.request({
url:'assertion.htm', // url of page where you want to send it
method: 'POST',
params: {
selectedSource:source.getValue() //Right hand side whatever value you want to send
},
scope:this
});

how pagination in the ext grid will work

I am using this article of architecture http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/
here is my Application.ResellerIroGrid.js
the pagination buttons are coming but no. of pages and pageno. is not coming .
Application.ResellerIroGrid = Ext.extend(Ext.grid.GridPanel, {
border:false
,cityname : ''
,columndataindex : ''
,fromdate:''
,todate : ''
,initComponent:function() {
var config = {
store:new Ext.data.JsonStore({
// store configs
autoDestroy: true,
autoLoad :false
,method: 'GET'
,baseParams: {
_command:'getresellersiro'
,city:this.cityname
,columndataindex : this.columndataindex
,fromdate : this.fromdate
,todate : this.todate
}
,url: 'api/index.php'
// reader configs
,root: 'reseller'
,totalProperty: 'totalcount'
,idProperty: 'mobile',
fields: [
{name: 'caller'},
{name: 'designa'},
{name: 'mobile'},
{name: 'app_date'},
{name: 'transferto'},
{name: 'data_city'},
{name: 'AllocatedTo'},
{name: 'Parentid'},
{name: 'gotthru'}
]
})
,columns: [
{
id :'caller',
header : 'Caller',
width : 120,
sortable : true,
dataIndex: 'caller'
},
{
id :'designa',
header : ' Designation',
width : 100,
sortable : true,
dataIndex: 'designa'
},
{
id :'mobile',
header : 'Mobile',
height : 50,
width : 100,
sortable : true,
dataIndex: 'mobile'
},
{
id :'app_date',
header : ' Appointment Date',
width : 100,
sortable : true,
dataIndex : 'app_date'
},
{
id :'transferto',
header : ' Transfered To',
width : 100,
sortable : true,
dataIndex: 'transferto'
},
{
id :'data_city',
header : ' Data City',
width : 100,
sortable : true,
dataIndex: 'data_city'
},
{
id :'AllocatedTo',
header : ' Allocated To',
width : 100,
sortable : true,
dataIndex: 'AllocatedTo'
},
{
id :'Parentid',
header : ' Parent Id',
width : 100,
sortable : true,
dataIndex: 'Parentid'
},
{
id :'gotthru',
header : ' Appointment Type',
width : 100,
sortable : true,
dataIndex: 'gotthru'
}
]
,plugins :[]
,viewConfig :{forceFit:true}
,tbar :[]
,bbar: new Ext.PagingToolbar({
pageSize: 5,
store: this.store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"
})
,height : 250
,width : 860
,title : 'Reseller Iro Grid'
}; // eo config object
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
Application.ResellerIroGrid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
,onRender:function() {
this.store.load();
Application.ResellerIroGrid.superclass.onRender.apply(this, arguments);
} // eo function onRender
});
Ext.reg('ResellerIroGrid', Application.ResellerIroGrid);
You need to have a totalProperty attribute in your Store or JsonReader config and this property must be sent by ther server JSON.
Eg :
,totalProperty: 'totalCount'
,root: 'reseller',
,idProperty: 'caller'
Also, dont hardcode params in the store url property. You should use the baseParams config option for this :
method:'GET'
,baseParams: {
_command:'getresellersiro'
,city:this.cityname
[...]
}
,url:'api/index.php'
And of course you should have a PagingToolbar declared for your grid in the initComponent :
var pagesize = 5;
var store = new Ext.data.JsonStore({
[...]
,params:{start:0, limit:pagesize}
});
var paging_toolbar = new Ext.PagingToolbar({
pageSize: pagesize,
displayInfo: true,
emptyMsg: 'No data',
store: store
});
var grid = new Ext.grid.GridPanel({
store:store,
[...]
bbar:paging_toolbar
});

ExtJS : BUtton actions when extending form panel

How can I call the formpanel.getForm() method when I am trying to override the Ext formpanel?
commentsForm = Ext.extend(Ext.form.FormPanel, {
frame: true,
initComponent: function() {
var config = {
frame : true,
autoScroll : true,
labelWidth : 150,
autoWidth : true,
labelPad : 20,
waitMsgTarget: true,
bodyStyle:'padding:0px 15px 15px 15px',
items: [{
xtype : 'fieldset',
title : 'Write Comment',
anchor : '100%',
defaults : {
selectOnFocus: true,
msgTarget: 'side',
xtype: 'textfield',
width : 200
},
items : [{
xtype : 'textarea',
name : 'comment',
allowBlank : false
}, {
name : 'added_by',
allowBlank : false
}, {
xtype : 'myndatefield',
name : 'added_at',
allowBlank : false,
value : new Date()
}]
}],
buttons: [{
text: 'Add',
handler : function() {
// TODO
var classForm = this.getForm();
console.log(this.getForm());
if (classForm.isValid()) {
console.log(classForm.findField("name"));
}
Ext.WindowMgr.hideAll();
}
}, {
text: 'Cancel',
handler : function() {
Ext.WindowMgr.hideAll();
}
}]
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
myn.commentsForm.superclass.initComponent.apply(this);
}
});
First in your code you are extending not overriding...
commentsForm.getForm() is a way to access BasicForm in your FormPanel if you place var at very beggining, however your code is confusing regarding name spaces: myn.commentsForm.superclass.initComponent.apply(this);

Resources