グリッドに並べ替えとフィルタリングを追加する必要があります。グリッドはタブパネルの一部です。Firebugで、コントローラーの呼び出しに対する次のパラメーターを確認できます。
_dc 1361741346485
limit 200
page 2
sort [{"property":"IsLate","direction":"ASC"}]
start 200
リクエストからソートパラメーターを受け入れるには、コントローラーメソッドにどのパラメーターを追加する必要がありますか?私はそれをシリアル化する必要があると思います。プロパティと方向を使用して並べ替えオブジェクトを作成しようとしましたが、デバッグすると、受け取ったパラメータのプロパティと方向がnullになります。従う必要のある命名規則はありますか?よくわかりません。ありがとうございました。
これは私のコードです:
LateGrid.js
Ext.define('FICMTB.ui.LateModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'Id' },
{ name: 'IsLate' },
{ name: 'Comments' },
{ name: 'Description' }],
idProperty: 'Id'
});
Ext.define("FICMTB.ui.LateGrid", {
extend: "Ext.grid.Panel",
requires: [
'FICMTB.ui.LateModel',
'Ext.ux.grid.FiltersFeature'
],
initComponent: function () {
var me = this;
me.columns = me.buildColumns();
me.filters = {
ftype: 'filters',
encode: false, // json encode the filter query
filters: [{
options: ['YES', 'NO'],
dataIndex: 'IsLate'
}]
};
me.features = [me.filters];
me.store = Ext.create('Ext.data.Store', {
model: 'FICMTB.ui.LateModel',
remoteSort: true,
storeId: 'LateStoreId',
autoLoad: true,
buffered: true,
autoSync: true,
pageSize: 200,
proxy: {
type: 'rest',
timeout: 600000,
url: '/Late/Transactions/',
reader: {
type: 'json',
root: 'transactions',
totalProperty: "Total"
},
writer: {
type: 'json',
root: 'transactions'
}
}
});
me.selModel = new Ext.selection.RowModel({
singleSelect: true
});
me.autoSizeColumns = true;
me.autoScroll = true;
me.forcefit = true;
me.callParent(arguments);
},
buildColumns: function () {
var me = this;
return [
{ text: 'Id', dataIndex: 'Id', hidden: true, hideable: false },
{ text: 'Is Late' dataIndex: 'IsLate', sortable: true, width: 50, filter:true},
{ text: 'Comments', dataIndex: 'Comments', width: 250, sortable: true },
{ text: 'Description', dataIndex: 'Description', width: 250, sortable: true }];
},
height: 600,
width: 'auto'
});
LateController.cs
[AcceptVerbs(HttpVerbs.Get)]
[ActionName("LateTransactions")]
public ActionResult GetLateTransactions(string page, string start, string limit, xxxxxx sorting, yyyyy filtering)
{
// what should xxxxx and yyyyy be? how should I name the sorting and filtering parameters?
// returns json
}
編集:Sortingオブジェクトを使用しようとしましたが、nullとして表示されます
// Sorting
// NOT Simple Sort:
// Request: index?sort=[{"property":"email","direction":"DESC"}, {"property":"last_name","direction":"ASC"}, ...]
public class Sorting
{
public string property { set; get; }
public string direction { set; get; }
}
[AcceptVerbs(HttpVerbs.Get)]
[ActionName("LateTransactions")]
public ActionResult GetLateTransactions(string page, string start, string limit, Sorting sort, yyyyy filtering)
{
....
}