mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-17 15:14:48 +02:00
several fixes for table, numberfield+DateField
This commit is contained in:
parent
0fe95a31c4
commit
665172eed0
@ -86,7 +86,7 @@ TableCellHandlerFactory::TableCellHandlerFactory()
|
||||
registerFactory(typeid(ImageButtonCell), pHandle);
|
||||
}
|
||||
{
|
||||
TableCellHandler<DateFieldCell>::Ptr pHandle(new TableCellHandler<DateFieldCell>(true, true));
|
||||
TableCellHandler<DateFieldCell>::Ptr pHandle(new TableCellHandler<DateFieldCell>(true, false));
|
||||
registerFactory(typeid(DateFieldCell), pHandle);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "Poco/WebWidgets/Table.h"
|
||||
#include "Poco/WebWidgets/WebApplication.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
#include "Poco/WebWidgets/DateFormatter.h"
|
||||
#include <sstream>
|
||||
|
||||
|
||||
@ -95,7 +96,12 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
ostr << "},";
|
||||
|
||||
renderColumns(pTable, context, ostr);
|
||||
ostr << ",clicksToEdit:1,store:";
|
||||
ostr << ",clicksToEdit:1";
|
||||
if (pTable->getWidth() > 0)
|
||||
ostr << ",width:" << pTable->getWidth();
|
||||
if (pTable->getHeight() > 0)
|
||||
ostr << ",height:" << pTable->getHeight();
|
||||
ostr << ",store:";
|
||||
renderStore(pTable, ostr);
|
||||
WebApplication::instance().registerAjaxProcessor(Poco::NumberFormatter::format(pTable), const_cast<Table*>(pTable));
|
||||
}
|
||||
@ -185,7 +191,7 @@ void TableRenderer::renderDataModel(const Table* pTable, std::ostream& ostr)
|
||||
if (col != 0)
|
||||
ostr << ",";
|
||||
|
||||
//FIXME: how do we distinguish if we want to write something as text or GUIElement?
|
||||
// how do we distinguish if we want to write something as text or GUIElement?
|
||||
// Example: Checkbutton can be written as text "true"/"false" or as a CheckButton
|
||||
// we use the Cell: if we have a Cell set -> complex Type otherwise text
|
||||
// -> already handled by the renderer!
|
||||
@ -201,7 +207,13 @@ void TableRenderer::renderDataModel(const Table* pTable, std::ostream& ostr)
|
||||
if (isString)
|
||||
ostr << "'" << RefAnyCast<std::string>(aVal) << "'";
|
||||
else if (ptrCell)
|
||||
ostr << tc[col]->getCell()->getFormatter()->format(aVal);
|
||||
{
|
||||
//date must be written as string
|
||||
if (typeid(Poco::DateTime) == aVal.type())
|
||||
ostr << "'" << tc[col]->getCell()->getFormatter()->format(aVal) << "'";
|
||||
else
|
||||
ostr << tc[col]->getCell()->getFormatter()->format(aVal);
|
||||
}
|
||||
else
|
||||
; //FIXME:
|
||||
}
|
||||
|
@ -479,10 +479,13 @@ std::string Utility::createFunctionCode(const std::string& eventName, const std:
|
||||
uri << RequestHandler::KEY_ID << "=" << id << "&";
|
||||
uri << RequestHandler::KEY_EVID << "=" << eventName;
|
||||
// add optional params
|
||||
bool commaAtEnd = false;
|
||||
std::size_t cnt(1);
|
||||
std::map<std::string, std::string>::const_iterator it = addParams.begin();
|
||||
for (; it != addParams.end(); ++it)
|
||||
for (; it != addParams.end(); ++it, ++cnt)
|
||||
{
|
||||
uri << "&" << it->first;
|
||||
uri << "&" << Utility::safe(it->first);
|
||||
commaAtEnd = false;
|
||||
if (it->second.empty())
|
||||
{
|
||||
}
|
||||
@ -491,15 +494,21 @@ std::string Utility::createFunctionCode(const std::string& eventName, const std:
|
||||
if (it->second[0] == '+')
|
||||
{
|
||||
// a variable was added
|
||||
uri << "='" << it->second << "+'";
|
||||
uri << "='" << it->second;
|
||||
if (cnt < addParams.size())
|
||||
{
|
||||
uri << "+'";
|
||||
}
|
||||
commaAtEnd = true;
|
||||
}
|
||||
else
|
||||
uri << "=" << it->second;
|
||||
uri << "=" << Utility::safe(it->second);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
uri << "'";
|
||||
if (!commaAtEnd)
|
||||
uri << "'";
|
||||
// now add the callback code
|
||||
std::ostringstream function;
|
||||
function << "function(" << JS_EVENTARGNAME << "){var uri=" << uri.str() << ";";
|
||||
|
@ -83,6 +83,12 @@ public:
|
||||
|
||||
const std::string& getHeader() const;
|
||||
/// Returns the header of the column
|
||||
|
||||
void setEditable(bool editable = true);
|
||||
/// Sets whether the Cell's contents can be edited.
|
||||
|
||||
bool isEditable() const;
|
||||
/// Returns true iff the Cell is editable.
|
||||
|
||||
|
||||
protected:
|
||||
@ -142,6 +148,18 @@ inline const std::string& TableColumn::getHeader() const
|
||||
}
|
||||
|
||||
|
||||
inline void TableColumn::setEditable(bool editable)
|
||||
{
|
||||
_pCell->setEditable(editable);
|
||||
}
|
||||
|
||||
|
||||
inline bool TableColumn::isEditable() const
|
||||
{
|
||||
return _pCell->isEditable();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
#include "Poco/WebWidgets/NumberFieldCell.h"
|
||||
#include "Poco/WebWidgets/IntFormatter.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -44,6 +45,7 @@ namespace WebWidgets {
|
||||
NumberFieldCell::NumberFieldCell(View* pOwner):
|
||||
TextFieldCell(pOwner, typeid(NumberFieldCell))
|
||||
{
|
||||
this->setFormatter(new IntFormatter());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user