PDA

View Full Version : Combo Start/Limit Does not change even clicking next page



innosia
4 Dec 2011, 6:47 PM
[HttpPost]
public JsonResult GetStockSymbol2(int start, int limit, string market, string query)
{
var result = _service.GetStockSymbol2(CQWebSession.ObjSession(HttpContext), query);
return Json(new { data = result.Skip(start).Take(limit), total = result.Count.ToString() }, JsonRequestBehavior.AllowGet);
}

Ext.define('CQT.store.trading.StockSymbol2', {
extend: 'Ext.data.Store',
fields: ['Market', 'Company_Code', 'Company_Name', 'ComInfo', 'FullName'],
id: 'Company_Code',
proxy: {
url: '../Trading/GetStockSymbol2',
type: 'ajax',
actionMethods: 'POST',
extraParams: { start: 0, limit: 6, market: '', query: '' }, // DEFAULT VALUE is used when clicking next page
reader: {
root: 'data',
totalProperty: 'total'
}
}
})

{
id: 'selectedSymbol',
name: 'selectedSymbol',
xtype: 'combo',
name: 'combo',
width:120,
hidden: false,
mode: 'remote',
emptyText: '(Input Symbol Here)',
displayField: 'Company_Code',
valueField: 'Company_Code',
resizable: false,
forceSelection:true,
store: store6,
pageSize: 6,
autoLoad: false,
minChars: 1,
matchFieldWidth: false,
minListWidth: 320,
listWidth:320,
listConfig:
{
width:320,
height:150
},
autoSelect: true,
enableKeyEvents: true,
loadingText: "wait...",
selectOnFocus: true,
listeners: {
loadexception: {
fn: function (proxy, store, response, e) {
Ext.MessageBox.alert(alert_lbl, "Fail Loading Symbol ");
}, scope: this
},
select: function (combo, record, index) {
var val = record[0].get("Company_Code");
val = trim(val);
this.setRawValue(val);
formPanel.down('[name=txtSelectedSymbol]').setValue(val);
currencyCombo.setValue('');
txtPrice.setValue('');
txtQuantity.setValue('');
currencyCombo.store.load({ params : { cocode: val } });
txtPrice.store.load({ params : { cocode: val } });
txtQuantity.store.load({ params : { cocode: val } });
//Ext.getCmp('selectedSymbol').setText(record.data["Company_Code"]);
//this.setRawValue(record.data.Company_Code);
},
blur : function() {
// var val = record[0].get("Company_Code");
// val = trim(val);
// //this.setRawValue.defer(1, [val]);
// this.setRawValue(val);
// formPanel.down('[name=txtSelectedSymbol]').setValue(val);
CheckSymbol();
//PopulateSettlementCurr();
},
expand: function (combo) {
var input = this.getRawValue();
store6.removeAll();
store6.load({ params: { start: combo.getParams().start, limit: combo.getParams().limit, query: input} });
},
keyup: function (txt, e) {
var input = this.getRawValue();
KeywordRegex = new RegExp(input, "i");
},
keypress: {
buffer: 1,
fn: function () {
if (!this.getRawValue()) {
this.doQuery('', true);
}
}
}
}
}




I finally figure out where to put totalProperty and root property, it is in the reader of store. And I after I put there, the combobox display the data correctly with paging. However when I click on the Next / Previous page, the MVC controller still receives start as 0 and limit as 6. Why is this happening?

I specify start 0 and limit 6 by the default, and EXT JS keeps using that value for every page (page 2, 3, etc). Is the way I implement combo box with paging correctly?

innosia
4 Dec 2011, 7:12 PM
Now it works after I remove default value from store and specify Nullable in the controller. And I check if it is null I will assume that it is page 0.

But now something weird happen, the pageSize I give to the combo is 6, however page 0 will have start as 0 and limit as 25, where is this 25 coming from? I never specify 25 as pageSize. How to make the pageSize to 6?

innosia
4 Dec 2011, 7:31 PM
I found that there are two pageSize

one is in Combo, which is used to make the bottom status bar (previous page, page 1, next page) to show. Which is required

another is in store, specify pageSize in the store will be correct


Ext.define('CQT.store.trading.AccountRef', {
extend: 'Ext.data.Store',
fields: ['SubAcct', 'CIO', 'B2BAcctNo', 'ClientName', 'B2BRemisierCode', 'NRIC', 'BranchName', 'AcctType'],
pageSize: 6,
proxy: {
url: '../Trading/GetAccountRef',
type: 'ajax',
actionMethods: 'POST',
extraParams: { query: '' },
reader: {
root: 'data',
totalProperty: 'total'
}
}
})


and reader to specify the root and totalProperty. Finally it works, now left other things

skirtle
4 Dec 2011, 9:45 PM
Please don't double post. I just wasted 15 minutes answering your other thread because I didn't know you'd already solved the problem.