Hi Christian,
thanks a lot for your help.
yes, this works fine: tableModel.setData([]);
but anyhow, I will take a look to the remote table model and try to use this
in future.
I will look how I can build in to my existing code.
best regards
Hans
2010/10/25 Christian Hagendorn <[email protected]>
> Hi Hans,
>
> I have done a look at your example. On each window "appear", you call
> the request and add the data to the table. In this case you have to
> reset the data before you add it again. I don't know if this works for
> resetting:
> tableModel.setData([]);
>
> But I would prefer to use the remote table model [1]. The model can be
> used to handle big set of data and it only does a request for the data
> which are seen at the moment.
>
> Cheers,
> Chris
>
> [1] http://demo.qooxdoo.org/current/apiviewer/#qx.ui.table.model.Remote
>
>
>
> Am 25.10.2010 10:37, schrieb Qoodary:
> > Hello,
> >
> > In my beginner app I build a table. The data comes from a database.
> > If you click on a button a new window open and shows the table and rows.
> > All works fine. For the first click the table shows 10 rows. But, if you
> > click the second time you see 20 rows. All data are duplicated. Next time
> > you see 30 rows.
> > I think I have a little logic problem :-)
> > The data from the remote request is ok, it is always 10 rows.
> >
> > The code for the table model:
> > ---------------------------------------------------
> > qx.Class.define("mytestapp.jobstatus",
> > {
> > extend : qx.ui.window.Window,
> >
> > construct : function(UserID) {
> >
> > // Call super class
> > this.base(arguments, this.tr("Job Status Information"));
> > var mycellrenderer = new mytestapp.MyCellRenderer();
> >
> > // Enable logging in debug variant
> > if (qx.core.Variant.isSet("qx.debug", "on"))
> > {
> > // support native logging capabilities, e.g. Firebug for Firefox
> > qx.log.appender.Native;
> > // support additional cross-browser console. Press F7 to toggle
> > visibility
> > qx.log.appender.Console;
> > }
> >
> > this.setLayout(new qx.ui.layout.VBox(10));
> > this.setStatus("Application is ready");
> >
> > var tableModel = new qx.ui.table.model.Simple();
> > tableModel.setColumns([ this.tr("State"), this.tr("FileName"),
> > this.tr("FileSize"), this.tr("Date") ]);
> >
> > var table = new qx.ui.table.Table(tableModel);
> > table.setLayoutProperties({top: 120});
> > table.setLayoutProperties({left: 200});
> > table.setWidth(500);
> > table.setHeight(200);
> >
> > with (table) {
> >
> >
> getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION);
> > setColumnWidth(0, 50);
> > setColumnWidth(1, 200);
> > setColumnWidth(2, 80);
> > setColumnWidth(3, 150);
> > };
> > this.add(table);
> >
> > var rowcount = tableModel.getRowCount();
> > //alert('Table row count is:' + rowcount);
> >
> > table.addListener('appear',function(){
> >
> > var req = new qx.io.remote.Request(
> > "http://localhost/mytestapp/jobstatus.php",
> > "GET",
> > "application/json");
> > req.addListener("completed", function(e) {
> > try
> > {
> > var content = e.getContent();
> > if (content.length> 0) {
> > //tableModel.setData(content);
> > var row;
> > var dateFormat = new
> qx.util.format.DateFormat("dd.MM.yyyy
> > HH:mm:ss");
> >
> > var tcm1 =
> table.getTableColumnModel();
> > // set column 3 to date
> format
> > var cellrenderer = new
> qx.ui.table.cellrenderer.Date();
> >
> cellrenderer.setDateFormat(new
> > qx.util.format.DateFormat("dd.MM.yyyy HH:mm:ss"));
> > tcm1.setDataCellRenderer(3,
> cellrenderer);
> >
> > for (var i=0;
> i<content.length; i++) {
> > row = [];
> > row[0] =
> content[i][0];
> > row[1] =
> content[i][1];
> > row[2] =
> content[i][2];
> > row[3] =
> dateFormat.parse(content[i][3]);
> >
> tableModel.addRows([row]);
> > }
> > }//if
> > }
> > catch (e)
> > {
> > alert("Fehler bei Erhalt des JobStatus: " +
> > e.toString());
> > }
> > });
> > req.setParameter("UserID", UserID);
> > //req.setParameter("UserID", 3);
> > req.send();
> > });
> > var tcm = table.getTableColumnModel();
> >
> > // Use the custom cell renderer for column 1
> > tcm.setDataCellRenderer(0, new mytestapp.MyCellRenderer());
> >
> > }//main function
> > //}//menbers
> > });
> >
> > any idea where the problem is? Is there a need to reset the table rows?
> >
> > best regards
> > Hans
>
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel