added remoteSort capability

This commit is contained in:
Peter Schojer
2008-10-01 07:40:33 +00:00
parent 00b1f3cde5
commit f870403250
8 changed files with 129 additions and 31 deletions

View File

@@ -38,6 +38,7 @@
#include "Poco/WebWidgets/ExtJS/TableRenderer.h"
#include "Poco/WebWidgets/ExtJS/Utility.h"
#include "Poco/WebWidgets/Table.h"
#include "Poco/WebWidgets/SortedTableModel.h"
#include "Poco/DateTime.h"
@@ -46,14 +47,18 @@ namespace WebWidgets {
namespace ExtJS {
void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, std::size_t rowBegin, std::size_t rowCntUser)
void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, std::size_t rowBegin, std::size_t rowCntUser, int sortCol, bool sortAscending )
{
//[
// ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
// ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am']
//]
// render the row-index as last column
const TableModel& tm = pTable->getModel();
SortedTableModel::Ptr pSorted;
if (sortCol >= 0)
pSorted = pTable->getSortedModel(static_cast<std::size_t>(sortCol), sortAscending);
const TableModel& tm = ((sortCol >= 0)?*pSorted:pTable->getModel());
const Table::TableColumns& tc = pTable->getColumns();
if (rowCntUser == 0 && pTable->getPagingSize() > 0)
rowCntUser = pTable->getPagingSize();

View File

@@ -673,7 +673,7 @@ void TableRenderer::onBeforeLoad(void* pSender, Table::LoadData& ld)
ld.pResponse->setChunkedTransferEncoding(true);
ld.pResponse->setContentType(ArrayTableSerializer::contentType());
std::ostream& out = ld.pResponse->send();
ArrayTableSerializer::serialize(out, ld.pTable, ld.firstRow, ld.rowCnt);
ArrayTableSerializer::serialize(out, ld.pTable, ld.firstRow, ld.rowCnt, ld.sortByColumn, ld.sortAscending);
}