Extjs 空阵列存储

Extjs 空阵列存储,extjs,extjs3,Extjs,Extjs3,我有一个参考商店的网格,如下所示: var s_store = new Ext.data.ArrayStore({ root: 'map', autoLoad: True, ... idProperty:'businessResults', url : '....', fields: someRecord });

我有一个参考商店的网格,如下所示:

var s_store = new Ext.data.ArrayStore({
            root: 'map',
            autoLoad: True,
            ...
            idProperty:'businessResults',
            url : '....',
            fields: someRecord
            });




        var s_grid= new Ext.grid.EditorGridPanel ({
        store: s_store,
        id: 's_grid',
        title:'Involvement',
        header: true,
        ....
        });

});
HTTP/1.1 200 OK
Date: Fri, 07 Feb 2014 03:41:12 GMT
Content-Length: 50
X-Powered-By: Servlet/2.5 JSP/2.1

{"map": [
  [
    "businessResults",
    {}
  ]
]}
存储从数据库加载数据记录。
我面临的问题是,虽然数据库不返回任何行,但存储区似乎显示计数为1(该行为空行)。
这将导致网格也显示emtpy行。 服务器的响应如下所示:

var s_store = new Ext.data.ArrayStore({
            root: 'map',
            autoLoad: True,
            ...
            idProperty:'businessResults',
            url : '....',
            fields: someRecord
            });




        var s_grid= new Ext.grid.EditorGridPanel ({
        store: s_store,
        id: 's_grid',
        title:'Involvement',
        header: true,
        ....
        });

});
HTTP/1.1 200 OK
Date: Fri, 07 Feb 2014 03:41:12 GMT
Content-Length: 50
X-Powered-By: Servlet/2.5 JSP/2.1

{"map": [
  [
    "businessResults",
    {}
  ]
]}
为什么会发生这种情况?我如何才能防止这种情况发生?

我使用的是extJs 3.4

我没有正确理解,但我对这个问题有一个建议。
JsonStore
中有一个属性是
totalProperty
。此属性跟踪Json数组的返回值。因此,您可以在返回值中放置一个计数器,如下所示:

// here is the count variable holding the total value of the array
$invoicesData = array("success" => true, "count" => $num, "invoices" => array());
return json_encode($invoicesData);
然后,在商店定义中:

var invoiceStore = new Ext.data.JsonStore({
   root: 'invoices',
   totalProperty: 'count',
   successProperty: 'success',
   proxy: new Ext.data.HttpProxy({
      url: 'your-server-url',
      method: 'POST'
   }),
   fields: ['CustomerName', 'StoreName',
      {name: 'StoreNo', type: 'int'},
      {name: 'invoiceId', type: 'int'}
   ],
   idProperty: 'invoiceId'
});
由于您已经将“map”设置为存储的根属性,并且在“map”下,您有一个将显示在网格中的空记录

   {"map": [
     [
       "businessResults",
       {}
     ]
  ]}
应该是这样的:

    {"map": [

    ]}
或者,如果记录在此对象下,则应将存储的根属性设置为“businessResults”


最好的

我想我们可能需要更多的代码,当
map
(根节点)为空时,
json
是什么样子?