mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-16 18:56:52 +02:00
afterload event added
This commit is contained in:
@@ -64,6 +64,7 @@ class ExtJS_API TableRenderer: public Poco::WebWidgets::Renderer
|
||||
public:
|
||||
static const std::string EV_CELLCLICKED;
|
||||
static const std::string EV_AFTEREDIT;
|
||||
static const std::string EV_AFTERLOAD;
|
||||
static const std::string HIDDEN_INDEX_ROW;
|
||||
|
||||
TableRenderer();
|
||||
@@ -86,6 +87,10 @@ public:
|
||||
/// Adds a javascript callback to inform the WebServer that the client has changed a value in the Table
|
||||
/// Method signature is cellclick : ( Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e )
|
||||
|
||||
static void addAfterLoadServerCallback(Table* pTable, const std::string& onSuccess=std::string(), const std::string& onFailure=std::string());
|
||||
/// Adds a javascript callback to inform the WebServer that the client has finished loading data
|
||||
/// Method signature is ( Store this, Ext.data.Record[] records, Object options )
|
||||
|
||||
protected:
|
||||
static void renderProperties(const Table* pTable, const RenderContext& context, std::ostream& ostr);
|
||||
/// Renders Table properties
|
||||
|
@@ -48,7 +48,7 @@ namespace ExtJS {
|
||||
|
||||
|
||||
const std::string PageRenderer::EV_BEFORERENDER("beforerender");
|
||||
const std::string PageRenderer::EV_AFTERRENDER("afterrender");
|
||||
const std::string PageRenderer::EV_AFTERRENDER("show"); //don't use afterrender which fires before all the children are rendered!
|
||||
|
||||
|
||||
PageRenderer::PageRenderer()
|
||||
@@ -97,6 +97,7 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
||||
{
|
||||
ostr << ",listeners:{";
|
||||
bool written = Utility::writeJSEvent(ostr, EV_BEFORERENDER, pPage->beforeRender.jsDelegates());
|
||||
//auto-show all windows
|
||||
JavaScriptEvent<Page*>::JSDelegates js = pPage->afterRender.jsDelegates();
|
||||
js.push_front(jsDelegate("function(){Ext.WindowMgr.each( function(w) {w.show(this);});}"));
|
||||
if (written && !js.empty())
|
||||
@@ -129,8 +130,7 @@ void PageRenderer::renderHead(const Renderable* pRenderable, const RenderContext
|
||||
}
|
||||
//close the panel
|
||||
ostr << "]});";
|
||||
//auto-show all windows
|
||||
//ostr << "Ext.WindowMgr.each( function(w) {w.show(this);});";
|
||||
|
||||
//close onReady
|
||||
ostr << "});";
|
||||
//close inline JS block
|
||||
|
@@ -43,8 +43,10 @@
|
||||
#include "Poco/WebWidgets/WebApplication.h"
|
||||
#include "Poco/WebWidgets/RequestHandler.h"
|
||||
#include "Poco/WebWidgets/DateFormatter.h"
|
||||
#include "Poco/WebWidgets/JSDelegate.h"
|
||||
#include "Poco/Delegate.h"
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -54,6 +56,7 @@ namespace ExtJS {
|
||||
|
||||
const std::string TableRenderer::EV_CELLCLICKED("cellclick");
|
||||
const std::string TableRenderer::EV_AFTEREDIT("afteredit");
|
||||
const std::string TableRenderer::EV_AFTERLOAD("load");
|
||||
const std::string TableRenderer::HIDDEN_INDEX_ROW("hidIdx");
|
||||
|
||||
|
||||
@@ -117,6 +120,16 @@ void TableRenderer::addCellValueChangedServerCallback(Table* pTable, const std::
|
||||
|
||||
|
||||
|
||||
void TableRenderer::addAfterLoadServerCallback(Table* pTable, const std::string& onSuccess, const std::string& onFailure)
|
||||
{
|
||||
poco_check_ptr (pTable);
|
||||
static const std::string signature("function(aStore, recs, op)");
|
||||
std::map<std::string, std::string> addParams;
|
||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, Table::EV_AFTERLOAD));
|
||||
Utility::addServerCallback(pTable->afterLoad, signature, addParams, pTable->id(), onSuccess, onFailure);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TableRenderer::addCellClickedServerCallback(Table* pTable, const std::string& onSuccess, const std::string& onFailure)
|
||||
{
|
||||
@@ -152,7 +165,6 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
if (written)
|
||||
ostr << ",";
|
||||
|
||||
|
||||
Utility::writeJSEvent(ostr, EV_CELLCLICKED, pTable->cellClicked.jsDelegates());
|
||||
|
||||
ostr << "},"; //close listeners
|
||||
@@ -282,12 +294,13 @@ void TableRenderer::renderStore(const Table* pTable, std::ostream& ostr)
|
||||
std::map<std::string, std::string> addParams;
|
||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID,Table::EV_LOADDATA));
|
||||
|
||||
|
||||
std::string url(Utility::createURI(addParams, pTable->id()));
|
||||
ostr << url << "}),";
|
||||
ostr << "reader:new Ext.data.ArrayReader()";
|
||||
//Write data
|
||||
/*ostr << "data:";
|
||||
renderDataModel(pTable, ostr);*/
|
||||
ostr << ",listeners:{";
|
||||
Utility::writeJSEvent(ostr, EV_AFTERLOAD, pTable->afterLoad.jsDelegates());
|
||||
ostr << "}";
|
||||
ostr << "})";
|
||||
}
|
||||
|
||||
|
@@ -69,8 +69,9 @@ public:
|
||||
static const std::string EV_CELLCLICKED;
|
||||
static const std::string EV_CELLVALUECHANGED;
|
||||
static const std::string EV_LOADDATA;
|
||||
static const std::string EV_AFTERLOAD;
|
||||
|
||||
struct CellClick
|
||||
struct WebWidgets_API CellClick
|
||||
{
|
||||
std::size_t row;
|
||||
std::size_t col;
|
||||
@@ -78,7 +79,7 @@ public:
|
||||
CellClick(std::size_t row, std::size_t col);
|
||||
};
|
||||
|
||||
struct CellValueChange
|
||||
struct WebWidgets_API CellValueChange
|
||||
/// Data sent with a cellValueChanged event.
|
||||
{
|
||||
std::size_t row;
|
||||
@@ -101,6 +102,8 @@ public:
|
||||
|
||||
JavaScriptEvent<Table::CellValueChange> cellValueChanged;
|
||||
|
||||
JavaScriptEvent<Table*> afterLoad; // thrown after data was loaded
|
||||
|
||||
FIFOEvent<LoadData> beforeLoad; /// thrown whenever a load is requested, internal event to which the TableRenderer must register
|
||||
|
||||
enum SelectionModel
|
||||
@@ -223,6 +226,7 @@ inline Table::SelectionModel Table::getSelectionModel() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
} } // namespace Poco::WebWidgets
|
||||
|
||||
|
||||
|
@@ -51,6 +51,7 @@ const std::string Table::FIELD_CNT("cnt");
|
||||
const std::string Table::EV_CELLCLICKED("click");
|
||||
const std::string Table::EV_CELLVALUECHANGED("edit");
|
||||
const std::string Table::EV_LOADDATA("load");
|
||||
const std::string Table::EV_AFTERLOAD("afterload");
|
||||
|
||||
|
||||
Table::Table(const TableColumns& tc, TableModel::Ptr pModel):
|
||||
@@ -174,6 +175,11 @@ void Table::handleAjaxRequest(const Poco::Net::NameValueCollection& args, Poco::
|
||||
setValue(Poco::Any(val), row, col);
|
||||
response.send();
|
||||
}
|
||||
else if (ev == EV_AFTERLOAD)
|
||||
{
|
||||
Table* pTable = this;
|
||||
afterLoad(this, pTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user