PDA

View Full Version : Ext JS 4 Combo Sample



innosia
4 Dec 2011, 6:14 PM
From server I am returning a property 'total' and 'data'. 'data' is a collection of a class which is the data


{ 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
}
}



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

[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);
}




Is above correct? Why the combo does not showing any result? And why its so difficult to find a sample for paginated combo for ext js 4, I search and can't find anything

skirtle
4 Dec 2011, 9:42 PM
A couple of examples of comboboxes that use paging:

http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/form/forum-search.html
http://skirtlesden.com/articles/extjs-comboboxes-part-2#Paging

Your totalProperty and root need to be specified on the reader, not directly on the store.

autoLoad should be on the store, not the combobox.

The mode setting was renamed queryMode from ExtJS 3 to 4.

You need to specify a pageSize on the store. You also shouldn't be specifying start, limit and query as extraParams.