mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-13 22:50:17 +02:00
added beforeselect event
This commit is contained in:
@@ -60,6 +60,7 @@ class ExtJS_API ComboBoxCellRenderer: public Poco::WebWidgets::Renderer
|
||||
{
|
||||
public:
|
||||
static const std::string EV_SELECTED;
|
||||
static const std::string EV_BEFORESELECT;
|
||||
static const std::string EV_AFTERLOAD;
|
||||
|
||||
ComboBoxCellRenderer();
|
||||
@@ -76,13 +77,18 @@ public:
|
||||
|
||||
private:
|
||||
static void onLoad(void* pSender, Poco::Net::HTTPServerResponse* &pResponse);
|
||||
|
||||
|
||||
static void serialize(const ComboBoxCell* pCell, std::ostream& out);
|
||||
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createSelectedServerCallback(const ComboBox* pCombo);
|
||||
/// Adds a server callback for the selected event. The method signature for select is
|
||||
/// select : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )
|
||||
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createBeforeSelectServerCallback(const ComboBox* pCombo);
|
||||
/// Adds a server callback for the beforeselect event. The method signature is
|
||||
/// beforeselect : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )
|
||||
/// return false to forbid it
|
||||
|
||||
static Poco::WebWidgets::JSDelegate createAfterLoadServerCallback(const ComboBox* pCombo);
|
||||
/// Create a server callback for afterLoad of ComboBox list
|
||||
};
|
||||
|
@@ -53,6 +53,7 @@ namespace ExtJS {
|
||||
|
||||
|
||||
const std::string ComboBoxCellRenderer::EV_SELECTED("select");
|
||||
const std::string ComboBoxCellRenderer::EV_BEFORESELECT("beforeselect");
|
||||
const std::string ComboBoxCellRenderer::EV_AFTERLOAD("load");
|
||||
|
||||
|
||||
@@ -77,6 +78,18 @@ JSDelegate ComboBoxCellRenderer::createSelectedServerCallback(const ComboBox* pC
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate ComboBoxCellRenderer::createBeforeSelectServerCallback(const ComboBox* pCombo)
|
||||
{
|
||||
// beforeselect : ( Ext.form.ComboBox combo, Ext.data.Record record, Number index )
|
||||
// return false to forbid it
|
||||
static const std::string signature("function(combo,rec,idx)");
|
||||
std::map<std::string, std::string> addParams;
|
||||
addParams.insert(std::make_pair(ComboBoxCell::FIELD_VAL, "+rec.get('d')"));
|
||||
addParams.insert(std::make_pair(RequestHandler::KEY_EVID, ComboBoxCell::EV_BEFORESELECT));
|
||||
return Utility::createServerCallback(signature, addParams, pCombo->id(), pCombo->beforeSelect.getOnSuccess(), pCombo->beforeSelect.getOnFailure());
|
||||
}
|
||||
|
||||
|
||||
Poco::WebWidgets::JSDelegate ComboBoxCellRenderer::createAfterLoadServerCallback(const ComboBox* pCombo)
|
||||
{
|
||||
poco_check_ptr (pCombo);
|
||||
@@ -118,11 +131,16 @@ void ComboBoxCellRenderer::renderHead(const Renderable* pRenderable, const Rende
|
||||
|
||||
std::string tooltip (pCell->getToolTip());
|
||||
|
||||
if (pComboOwner && (pComboOwner->selected.hasJavaScriptCode() || !tooltip.empty()))
|
||||
if (pComboOwner && (pComboOwner->selected.hasJavaScriptCode() || !tooltip.empty() || pComboOwner->beforeSelect.hasJavaScriptCode()))
|
||||
{
|
||||
ostr << ",listeners:{";
|
||||
bool written = Utility::writeJSEvent(ostr, EV_SELECTED, pComboOwner->selected, &ComboBoxCellRenderer::createSelectedServerCallback, pComboOwner);
|
||||
|
||||
if (pComboOwner->beforeSelect.hasJavaScriptCode())
|
||||
{
|
||||
if (written)
|
||||
ostr << ",";
|
||||
written = Utility::writeJSEvent(ostr, EV_BEFORESELECT, pComboOwner->beforeSelect, &ComboBoxCellRenderer::createBeforeSelectServerCallback, pComboOwner);
|
||||
}
|
||||
if (!tooltip.empty())
|
||||
{
|
||||
if (written)
|
||||
|
Reference in New Issue
Block a user