我使用 node 开发了我的应用程序,该应用程序应该在页面上加载3800条或更多记录,并将其显示在表上。我设法创建了一些过滤器,当我应用它们时,该页面需要一段时间才能回复。我创建的过滤器只是客户端,它们所做的唯一一件事就是将表中的元素隐藏在过滤器之外。
这是我的服务器端代码:
app.get('/query', (req,res) =>{
sql='SELECT u.sendingdate, cl.alias, u.customerkey, cl.idCliente, u.media, cl.nomeCliente, i.Nazione, u.itemkey, u.publicationname, u.publicationkey FROM uploads AS u LEFT JOIN customer AS cl ON cl.idCliente = u.idCliente LEFT JOIN rubric AS r ON r.idRubric = u.customerkey LEFT JOIN tab_iso AS i ON u.countryisocode = i.ISO WHERE u.sendingdate >= "' + start + '" AND u.sendingdate <= "' + end + '" GROUP BY c.id;'
con.query(sql, (err, uploads, fields) =>{
if (err) throw err;
con.query('SELECT i.Nations FROM uploads AS u LEFT JOIN tab_iso AS i ON u.countryisocode = i.ISO GROUP BY Nations;', (err, nations, fields) =>{
if (err) throw err;
res.render('query.ejs', {uploads: uploads, nations: nations})
//SELECT ... FROM ... WHERE somecol >= '2011-01-01' AND somecol <= '2011-01-30'
})
})
})
这是页面,我使用ejs:
<table id="table" cellspacing="0" class="ui sortable celled table display" style="width:100%">
<thead>
<tr>
<th class="">Item Key</th>
<th class="">Date</th>
<th class="">Nation</th>
<th class="">Alias</th>
<th class="">Customer Name</th>
<th class="">Media</th>
<th class="">GMDID</th>
<th class="">Headline</th>
</tr>
</thead>
<tbody id="tbody">
<% for(var i = 0; i < uploads.length; i++) { %>
<tr class="record">
<td><%= uploads[i]["itemkey"] %></td>
<td><%= uploads[i]["sendingdate"] %></td>
<td class="nationC"><%= uploads[i]['Nazione'] %></td>
<td><%= uploads[i]["alias"] %></td>
<td><%= uploads[i]["nomeCliente"] %></td>
<td><%= uploads[i]["media"] %></td>
<td><%= uploads[i]["publicationkey"] %></td>
<td><%= uploads[i]["publicationname"] %></td>
</tr>
<% } %>
<p id="counter"><%= i %></p>
</tbody>...