ExtJS form sended twice
extjs, extjs4, filter, forms, request
Solution
Try following
if(filters.length > 0)
listOfSites.filters.addFilters(filters);
else
listOfSites.store.load();
`addFilters()` may already call `sync()`
Problem
I have a form with search (filtering) fields like this: ``` xtype: 'form', id: 'searchPanel', title: 'Search', collapsible: true, bodyPadding: 10, height: 210, buttonAlign: 'left', defaults: { width: 400, labelWidth: 120, allowBlank: true, enableKeyEvents: true }, layout: { type: 'table', columns: 2 }, items: [ { xtype: 'textfield', name: 'txtFltrSiteName', fieldLabel: 'Site name or alias', id: 'txtFltrSiteName' }, { xtype: 'textfield', name: 'txtMonthTraffic', fieldLabel: 'Month traffic', id: 'txtMonthTraffic', style: 'margin-left: 100px;' }, { xtype: 'combo', id: 'ddlFltrPM', name: 'ddlFltrPM', fieldLabel: 'Project manager', displayField: 'display_name', valueField: 'user_id', editable: false, store: new storeOfUsers({ filters: [{ property: 'user_group_code', value: 'projectmanager', exactMatch: true }] }) }, // and many other fields below ``` But when i click on `search` button, i have two post request. One - with filter in it, second is without. My code for `send` button action: ``` xtype: 'button', id: 'btn_srch_set', text: 'Searh', margin: '10 7 0 0', width: '', handler: function() { var filters = new Array(); var site_name = Ext.getCmp('txtFltrSiteName').getValue(); if(site_name.length > 0) filters.push({dataIndex: 'site_name', type: 'string', value: site_name}); var project_name = Ext.getCmp('txtFltrProjectName').getValue(); if(project_name.length > 0) filters.push({dataIndex: 'project_name', type: 'string', value: project_name}); var pm = Ext.getCmp('ddlFltrPM').getValue(); if(pm && pm > 0) filters.push({dataIndex: 'project_manager_id', type: 'int', value: {'eq':pm}}); // many other fields listOfSites.filters.removeAll(); if(filters.length > 0) listOfSites.filters.addFilters(filters); listOfSites.store.load(); } ``` P.S. When I overwrite in `search` button handler function this line: `filters.push({dataIndex: 'project_manager_id', type: 'string', value: pm});` Evrything is ok and there is only one request, so problem might be here. But i'm stuck and have no idea why it works such way. Thanks for any help, Stanislav. UPD* ``` var filters = { ftype: 'filters', // encode and local configuration options defined previously for easier reuse encode: true, // json encode the filter query local: false, filters: [{ type: 'string', dataIndex: 'site_name' }, { type: 'date', dataIndex: 'startdate' }, { type: 'string', dataIndex: 'project_name' // more fields below ```