Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Fetch last 20 rows from a Database

$
0
0
Hi,
I'm using SmartGWT Pro and I have a ListGrid with a DataSource that's connected to a MySQL Database. The datasource is defined through a XML-file and looks like this:

Code:

<DataSource ID="messageSummary" serverType="sql" tableName="message_summary">

        <fields>
                <field name="id"          title="ID"        type="sequence" primaryKey="true" hidden="true" canExport="false" export="false"/>
        <field name="sequence_number" title="Number" type="integer" width="100" align="center"/>
                <field name="date"        title="Date"      type="text"    width="100" align="center"/>
        <field name="time"        title="Time"      type="text"    width="100" align="center"/>
        <field name="type"        title="Type"      type="text"    align="left"/>
        </fields>
       
</DataSource>

I'm using a Timer on the client-side to refresh the content every second, but I'm only interested in the last 20 rows. Is it possible to tell the fetch operation to only fetch the last 20 rows? In SQL I would have written something like
Code:

select * from tbl_name order by id desc limit 20;
I know that I can use
Code:

n = (no. of rows)
DSRequest.setStartRow(n-20)
DSRequest.setEndRow(n)

but I don't know number of rows.

Viewing all articles
Browse latest Browse all 4756

Trending Articles