このプログラムは、getTotalCount() の値が数値 (たとえば 10) より大きいかどうかをチェックし、大きい場合は警告ウィンドウを表示する必要があります。
私の問題は、 getTotalCount() の値を変数に割り当てる方法です。
var Store = new Ext.data.Store({
id: 'ID_Store',
proxy: new Ext.data.HttpProxy({
url: 'get.php',
method: 'POST'
}),
baseParams:{task: "LIST"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'IDclass', type: 'int', mapping: 'id_class'},
{name: 'Class', type: 'string', mapping: 'class'}
])
});
Store.load;
var total_num = Store.getTotalCount();
if(total_num > 10){
alert("greater than 10");
}
JSON は次のとおりです。
{success:true}{total:23,results:[{"id_class":"1","class":"V-1"},{"id_class":"2","class":"V-2"},{"id_class":"3","class":"V-3"},{"id_class":"4","class":"V-4"},{"id_class":"5","class":"V-5"},{"id_class":"6","class":"VI-1"},{"id_class":"7","class":"VI-2"},{"id_class":"8","class":"VI-3"},{"id_class":"9","class":"VI-4"},{"id_class":"10","class":"VI-5"},{"id_class":"11","class":"VII-1"},{"id_class":"12","class":"VII-2"},{"id_class":"13","class":"VII-3"},{"id_class":"14","class":"VII-4"},{"id_class":"15","class":"VII-5"},{"id_class":"16","class":"VIII-1"},{"id_class":"17","class":"VIII-2"},{"id_class":"18","class":"VIII-3"},{"id_class":"19","class":"VIII-4"},{"id_class":"20","class":"VIII-5"}]}