mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-16 18:56:52 +02:00
added editmode support
This commit is contained in:
@@ -76,6 +76,7 @@ public:
|
||||
static const std::string EV_KEYPRESSED;
|
||||
static const std::string EV_ROWSELECTED;
|
||||
static const std::string EV_CELLSELECTED;
|
||||
static const std::string EV_STARTCELLVALUECHANGE;
|
||||
static const std::string HIDDEN_INDEX_ROW;
|
||||
|
||||
TableRenderer();
|
||||
@@ -100,6 +101,11 @@ public:
|
||||
/// containing members (grid, record, column, row, value, cancel)!
|
||||
/// obj.cancel must be set to false to forbid the edit
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createStartCellValueChangeServerCallback(const Table* pTable);
|
||||
/// Adds a javascript callback to inform the WebServer that the client has entered edit mode in the Table
|
||||
/// The Extjs handler offers a method signature of "function(obj)" where obj is a complex element
|
||||
/// containing members (grid, record, column, row, value, cancel)!
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createCellSelectedServerCallback(const Table* pTable);
|
||||
/// Adds a javascript callback to inform the WebServer that the client has selected a cell
|
||||
/// The Extjs handler offers a method signature of
|
||||
|
@@ -59,6 +59,7 @@ const std::string TableRenderer::EV_ROWCLICKED("rowclick");
|
||||
const std::string TableRenderer::EV_BEFORECELLCLICKED("cellmousedown");
|
||||
const std::string TableRenderer::EV_BEFOREROWCLICKED("rowmousedown");
|
||||
const std::string TableRenderer::EV_BEFORECELLVALUECHANGED("validateedit");
|
||||
const std::string TableRenderer::EV_STARTCELLVALUECHANGE("beforeedit");
|
||||
const std::string TableRenderer::EV_AFTEREDIT("afteredit");
|
||||
const std::string TableRenderer::EV_AFTERLOAD("load");
|
||||
const std::string TableRenderer::EV_RENDER("render");
|
||||
@@ -316,6 +317,31 @@ Poco::WebWidgets::JSDelegate TableRenderer::createKeyPressedServerCallback(const
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate TableRenderer::createStartCellValueChangeServerCallback(const Table* pTable)
|
||||
{
|
||||
// beforeedit : ( Object e )
|
||||
// * grid - This grid
|
||||
// * record - The record being edited
|
||||
// * field - The field name being edited
|
||||
// * value - The value for the field being edited.
|
||||
// * row - The grid row index
|
||||
// * column - The grid column index
|
||||
// * cancel - Set this to true to cancel the edit or return false from your handler.
|
||||
|
||||
poco_check_ptr (pTable);
|
||||
static const std::string signature("function(e)");
|
||||
//extract the true row index from the last column!
|
||||
std::string origRow("+e.grid.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_STARTCELLVALUECHANGE));
|
||||
return Utility::createServerCallback(signature, addParams, pTable->id(), pTable->startCellValueChange.getOnSuccess(), pTable->startCellValueChange.getOnFailure());
|
||||
}
|
||||
|
||||
|
||||
void TableRenderer::renderProperties(const Table* pTable, const RenderContext& context, std::ostream& ostr)
|
||||
{
|
||||
WebApplication& app = WebApplication::instance();
|
||||
@@ -341,6 +367,13 @@ void TableRenderer::renderProperties(const Table* pTable, const RenderContext& c
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFORECELLVALUECHANGED, pTable->beforeCellValueChanged,
|
||||
&TableRenderer::createBeforeCellValueChangedServerCallback, pTable);
|
||||
}
|
||||
|
||||
if (pTable->startCellValueChange.hasJavaScriptCode())
|
||||
{
|
||||
if (written) ostr << ",";
|
||||
written = Utility::writeJSEvent(ostr, EV_STARTCELLVALUECHANGE, pTable->startCellValueChange,
|
||||
&TableRenderer::createStartCellValueChangeServerCallback, pTable);
|
||||
}
|
||||
}
|
||||
|
||||
if (pTable->keyDown.hasJavaScriptCode())
|
||||
|
@@ -82,8 +82,8 @@ void TextFieldCellRenderer::renderBody(const Renderable* pRenderable, const Rend
|
||||
void TextFieldCellRenderer::writeCellProperties(const TextFieldCell* pCell, std::ostream& ostr, bool writeValue, bool writeListeners)
|
||||
{
|
||||
Utility::writeCellProperties(pCell, ostr);
|
||||
|
||||
ostr << ",selectOnFocus:true";
|
||||
if (pCell->getEditMode() == Cell::EM_SELECTCONTENT)
|
||||
ostr << ",selectOnFocus:true";
|
||||
|
||||
if (writeValue&& !pCell->getValue().empty())
|
||||
{
|
||||
|
Reference in New Issue
Block a user