Qooxdoo远程表getRowCount()返回0

时间:2017-01-20 02:52:29

标签: qooxdoo


    qx.Class.define("webApp.backendjs.tables.RegionesModel", {
        extend: qx.ui.table.model.Remote,
        members: {
            _loadRowCount: function () {
                var params = {};
                params.action = "getCount";
                var rpc = new qx.io.remote.Rpc("http://qx.alpali.cl/svc/svc.php");
                rpc.setProtocol("2.0");
                rpc.setCrossDomain(true);
                rpc.callAsync(qx.lang.Function.bind(this._onRowCountCompleted, this), "regiones.regiones.getNominaRegiones", params);
            },

            _onRowCountCompleted: function (result, exc) {
                if (result !== null) {
                    this._onRowCountLoaded(result.count);
                }
            },

            _loadRowData: function (firstRow, lastRow) {
                var params = {};
                params.action = "getData";
                var rpc = new qx.io.remote.Rpc("http://qx.alpali.cl/svc/svc.php");
                rpc.setProtocol("2.0");
                rpc.setCrossDomain(true);
                rpc.callAsync(qx.lang.Function.bind(this._onLoadRowDataCompleted, this), "regiones.regiones.getNominaRegiones", params);
            },

            _onLoadRowDataCompleted: function (result, exc) {
                if (result !== null) {
                    this._onRowDataLoaded(result);
                }
            }
        }
    });

    var RTRegionesModel = new webApp.backendjs.tables.RegionesModel();
    RTRegionesModel.setColumns(["ID", "C贸digo", "Nombre"], ["id", "region_id", "region_nombre"]);

    var TableRegiones = new qx.ui.table.Table(RTRegionesModel);
    TableRegiones.setTableModel(RTRegionesModel);

    // THIS don't work, return 0
    TableRegiones.addListener('appear', function () {
        console.log("RTRegionesModel.getRowCount(): %s", RTRegionesModel.getRowCount());
    }, RTRegionesModel);

    // THIS don't work, return 0
    TableRegiones.addListener('appear', function () {
        console.log("RTRegionesModel.getRowCount(): %s", RTRegionesModel.getRowCount());
    }, this);

    this.getRoot().add(TableRegiones);

    var button1 = new qx.ui.form.Button("How many record...", "icon/22/apps/internet-web-browser.png");
    this.getRoot().add(button1,{right:50,top:50});

    // this is ok, return teh value
    button1.addListener("execute", function(e) {
      console.log("RTRegionesModel.getRowCount(): %s", RTRegionesModel.getRowCount());
    });

测试游乐场的网址

我需要加载远程表时的勇气

问题是什么.. ???

感谢。

PD:抱歉我的英文不好和丑陋,我的母语是西班牙语(智利),我现在最好的朋友是googol

1 个答案:

答案 0 :(得分:1)

当您使用“此操作”注释查找行计数时,行计数尚不可用,因为尚未发出从服务器检索行计数的网络操作。

您可能希望监听模型的dataChanged事件,该事件在加载行计数或模型数据更改时触发,例如:

TableRegiones.getTableModel().addListener(
  'dataChanged',
  function ()
  {
    console.log(
      "dataChanged: RTRegionesModel.getRowCount(): %s",
      RTRegionesModel.getRowCount());
  },
  RTRegionesModel);