mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 06:55:49 +02:00
more Table events
This commit is contained in:
@@ -64,6 +64,8 @@ class ExtJS_API TableRenderer: public Poco::WebWidgets::Renderer
|
||||
public:
|
||||
static const std::string EV_CELLCLICKED;
|
||||
static const std::string EV_ROWCLICKED;
|
||||
static const std::string EV_BEFORECELLCLICKED;
|
||||
static const std::string EV_BEFOREROWCLICKED;
|
||||
static const std::string EV_AFTEREDIT;
|
||||
static const std::string EV_AFTERLOAD;
|
||||
static const std::string EV_RENDER;
|
||||
@@ -97,6 +99,16 @@ public:
|
||||
/// Single cell selection will trigger an exception!
|
||||
/// Method signature is rowselect : ( SelectionModel this, Number rowIndex, Ext.Data.Record r )
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createBeforeCellClickedServerCallback(const Table* pTable);
|
||||
/// Adds a javascript callback to inform the WebServer that the client has clicked on a cell in the Table
|
||||
/// Method signature is cellclick : ( Grid this, Number rowIndex, Number columnIndex, Ext.EventObject e )
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createBeforeRowClickedServerCallback(const Table* pTable);
|
||||
/// Adds a javascript callback to inform the WebServer that the client has clicke don a row
|
||||
/// This event will only be added if the Table uses a Row selection model!
|
||||
/// Single cell selection will trigger an exception!
|
||||
/// Method signature is rowselect : ( SelectionModel this, Number rowIndex, Ext.Data.Record r )
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createAfterLoadServerCallback(const Table* pTable);
|
||||
/// 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 )
|
||||
|
@@ -56,6 +56,8 @@ namespace ExtJS {
|
||||
|
||||
const std::string TableRenderer::EV_CELLCLICKED("cellclick");
|
||||
const std::string TableRenderer::EV_ROWCLICKED("rowselect");
|
||||
const std::string TableRenderer::EV_BEFORECELLCLICKED("cellmousedown");
|
||||
const std::string TableRenderer::EV_BEFOREROWCLICKED("rowmousedown");
|
||||
const std::string TableRenderer::EV_AFTEREDIT("afteredit");
|
||||
const std::string TableRenderer::EV_AFTERLOAD("load");
|
||||
const std::string TableRenderer::EV_RENDER("render");
|
||||
@@ -161,6 +163,22 @@ Poco::WebWidgets::JSDelegate TableRenderer::createCellClickedServerCallback(cons
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate TableRenderer::createBeforeCellClickedServerCallback(const Table* pTable)
|
||||
{
|
||||
poco_check_ptr (pTable);
|
||||
static const std::string signature("function(theGrid,row,col,e)");
|
||||
//extract the true row index from the last column!
|
||||
std::string origRow("+theGrid.getStore().getAt(row).get('");
|
||||
origRow.append(Poco::NumberFormatter::format(static_cast<Poco::UInt32>(pTable->getColumnCount())));
|
||||
origRow.append("')");
|
||||
std::map<std::string, std::string> addParams;
|
||||
addParams.insert(std::make_pair(Table::FIELD_COL, "+col"));
|
||||
addParams.insert(std::make_pair(Table::FIELD_ROW, origRow));
|
||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, Table::EV_BEFORECELLCLICKED));
|
||||
return Utility::createServerCallback(signature, addParams, pTable->id(), pTable->beforeCellClicked.getOnSuccess(), pTable->beforeCellClicked.getOnFailure());
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate TableRenderer::createRowClickedServerCallback(const Table* pTable)
|
||||
{
|
||||
poco_check_ptr (pTable);
|
||||
@@ -179,6 +197,24 @@ Poco::WebWidgets::JSDelegate TableRenderer::createRowClickedServerCallback(const
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate TableRenderer::createBeforeRowClickedServerCallback(const Table* pTable)
|
||||
{
|
||||
poco_check_ptr (pTable);
|
||||
poco_assert (pTable->getSelectionModel() != Table::SM_CELL);
|
||||
|
||||
/// Method signature is rowselect : ( SelectionModel this, Number rowIndex, Ext.Data.Record r )
|
||||
static const std::string signature("function(sm,row,r)");
|
||||
//extract the true row index from the last column!
|
||||
std::string origRow("+r.get('");
|
||||
origRow.append(Poco::NumberFormatter::format(static_cast<Poco::UInt32>(pTable->getColumnCount())));
|
||||
origRow.append("')");
|
||||
std::map<std::string, std::string> addParams;
|
||||
addParams.insert(std::make_pair(Table::FIELD_ROW, origRow));
|
||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, Table::EV_BEFOREROWCLICKED));
|
||||
return Utility::createServerCallback(signature, addParams, pTable->id(), pTable->beforeRowClicked.getOnSuccess(), pTable->beforeRowClicked.getOnFailure());
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate TableRenderer::createMouseUpServerCallback(const Table* pTable)
|
||||
{
|
||||
poco_check_ptr (pTable);
|
||||
@@ -238,6 +274,18 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
written = Utility::writeJSEvent(ostr, EV_CELLCLICKED, pTable->cellClicked.jsDelegates());
|
||||
}
|
||||
|
||||
if (pTable->beforeCellClicked.hasJavaScriptCode())
|
||||
{
|
||||
if (written)
|
||||
ostr << ",";
|
||||
if (pTable->beforeCellClicked.willDoServerCallback())
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFORECELLCLICKED, pTable->beforeCellClicked.jsDelegates(),
|
||||
TableRenderer::createBeforeCellClickedServerCallback(pTable),
|
||||
pTable->beforeCellClicked.getServerCallbackPos());
|
||||
else
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFORECELLCLICKED, pTable->beforeCellClicked.jsDelegates());
|
||||
}
|
||||
|
||||
if (pTable->afterRender.hasJavaScriptCode())
|
||||
{
|
||||
if (written)
|
||||
@@ -289,15 +337,27 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
ostr << ",selModel:new Ext.grid.RowSelectionModel({singleSelect:true";
|
||||
else if (pTable->getSelectionModel() == Table::SM_MULTIROW)
|
||||
ostr << ",selModel:new Ext.grid.RowSelectionModel({singleSelect:false";
|
||||
if (pTable->rowClicked.hasJavaScriptCode())
|
||||
if (pTable->rowClicked.hasJavaScriptCode() || pTable->beforeRowClicked.hasJavaScriptCode())
|
||||
{
|
||||
ostr << ",listeners:{";
|
||||
if (pTable->rowClicked.willDoServerCallback())
|
||||
Utility::writeJSEvent(ostr, EV_ROWCLICKED, pTable->rowClicked.jsDelegates(),
|
||||
written = Utility::writeJSEvent(ostr, EV_ROWCLICKED, pTable->rowClicked.jsDelegates(),
|
||||
TableRenderer::createRowClickedServerCallback(pTable),
|
||||
pTable->rowClicked.getServerCallbackPos());
|
||||
else
|
||||
Utility::writeJSEvent(ostr, EV_ROWCLICKED, pTable->rowClicked.jsDelegates());
|
||||
written = Utility::writeJSEvent(ostr, EV_ROWCLICKED, pTable->rowClicked.jsDelegates());
|
||||
|
||||
if (pTable->beforeRowClicked.hasJavaScriptCode())
|
||||
{
|
||||
if (written)
|
||||
ostr << ",";
|
||||
if (pTable->beforeRowClicked.willDoServerCallback())
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFOREROWCLICKED, pTable->beforeRowClicked.jsDelegates(),
|
||||
TableRenderer::createBeforeRowClickedServerCallback(pTable),
|
||||
pTable->beforeRowClicked.getServerCallbackPos());
|
||||
else
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFOREROWCLICKED, pTable->beforeRowClicked.jsDelegates());
|
||||
}
|
||||
ostr << "}";
|
||||
}
|
||||
ostr << "})"; //close selModel
|
||||
|
Reference in New Issue
Block a user