mirror of
https://github.com/pocoproject/poco.git
synced 2025-12-24 14:19:08 +01:00
added remoteSort capability
This commit is contained in:
@@ -55,7 +55,7 @@ class ExtJS_API ArrayTableSerializer
|
||||
/// ArrayTableSerializer serializes a Table in JSON format
|
||||
{
|
||||
public:
|
||||
static void serialize(std::ostream& ostr, const Poco::WebWidgets::Table* pTable, std::size_t rowBegin = 0, std::size_t rowCnt = 0);
|
||||
static void serialize(std::ostream& ostr, const Poco::WebWidgets::Table* pTable, std::size_t rowBegin = 0, std::size_t rowCnt = 0, int sortCol = -1, bool sortAscending = true);
|
||||
/// Serializes the table starting with row 0. A rowCnt of 0 means serialize all rows
|
||||
|
||||
static const std::string& contentType();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user