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?
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?